...
Excerpt |
---|
Backport allows you to check the status of any what alterations, if any, have been made to a JS API feature so that your script can act accordingly. |
Availability
Backport.js v0.1 and above
Syntax
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
var returnValue = backport("featureName"name); |
Parameters
Parameter | Type | Mandatory | Description | Backport version |
---|---|---|---|---|
featureNamename | String | The name (key) of the feature as a string (in quotes). | 0.1 |
...
It's important to remember that Javascript uses type coercion - see Examples below for more information.
Examples
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
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
...
- Listing API features – get a list of names for all defined JS API features
- How does Backport work? – understand how all this works under the hood