Overview
Backport allows you to check the status of any JS API feature so that your script can act accordingly.Availability
Backport v0.1 and above
Syntax
var returnValue = backport("featureName");
Parameters
Parameter | Type | Mandatory | Description | Backport version |
---|---|---|---|---|
featureName | String | The name (key) of the feature as a string (in quotes). | 0.1 |
Return values
Value | Type | Summary | Description | Backport version |
---|---|---|---|---|
-1 | Number | Added | Feature was missing from JS API, but has been added via backports. | 0.1 |
1 | Number | Upgraded | Feature was present in JS API, but has been upgraded/extended by backports. | 0.1 |
null | Null | Removed | Feature was present in JS API, but has been removed by backports. (Deprecated features are removed if new approach is backported). | 0.1 |
true | Boolean | Native | Feature is present in JS API, has not been altered by backports. | 0.1 |
undefined | Boolean | Missing | Feature missing from JS API. | 0.1 |
It's important to remember that Javascript uses type coercion - see Examples below for more information.
Examples
var status = backport("orderDroid"); // orderDroid() was added in Warzone 3.2 // basic type coercion examples if (status) { // the feature exists // status could be true, -1 or 1 } if (!status) { // the feature does not exist // status could be null or undefined } // remember that == (equality operator) also type coerces! if (status == true) { // status could be true, -1 or 1 } if (status != true) { // status could be null or undefined } if (status == null) { // status could be null or undefined } // use === (strict equality operator) if you need to check a specific value if (status === -1) { // the feature was added by a backport script // status must be exactly -1 } if (status === null) { // a deprecated feature was removed // status must be exactly null } if (status === true) { // the native, unaltered feature is present // status must be exactly true }
See also