Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Backport.js v0.1 and above

Syntax

Code Block
themeRDark
languagejavascript
linenumberstrue
var returnValue = backport(name);

...

It's important to remember that Javascript uses type coercion - see Examples below for more information.

Examples

Code Block
themeRDark
languagejavascript
linenumberstrue
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
}

...