Listing API features

Overview

Backport allows you get a list of the names of all JS API features, including those added by backport scripts.

Availability

Backport.js v0.1 and above

Syntax

var returnValue = backport();

Parameters

Do not specify any parameters.

Return values

ValueTypeDescriptionBackport version
<array>Array of StringsAn array containing the names of all JS API features that are present.0.1

Example

// console the status of each feature
backport().forEach(function(feature) {
  switch (backport(feature)) {
    case -1: { // added
      console(feature+" was missing but has been added by a backport script");
      break;
    }
    case 1: { // upgraded/extended
      console(feature+" was present but has been upgraded/extended by a backport script");
      break;
    }
    case undefined: { // missing
      // note: this will never happen as backport() doesn't list missing features
      console(feature+" is missing");
      break;
    }
    case null: { // deprecated
      console(feature+" was present but has been removed by a backport script because it's deprecated");
      break;
    }
    case true: { // native
     console(feature+" is present and has *not* been altered by backport scripts");
     break;
    }
  }
});

See also

  • Check status of an API feature – check status of a specific backport feature (including examples of type coercion which you should be aware of before using!)