inOperator for Arrays- typeof operator
- The new keyword
- instanceof behavior
- C-style for loop scope
- arguments in Arrow Functions
- decodeURI / decodeURIComponent Error Handling
- Undeclared variables and temporal dead zone
- Property access on null / undefined
- Arithmetic coercion
- Not supported
- Method whitelisting
- Additional features (not in standard JS)
- Comments and semicolons
- Next steps
Part of the Scripting Language reference.
The script engine is JS-like but not identical to standard JavaScript. This page documents all known differences.
in Operator for Arrays
Checks if a value exists in the array (like array.includes(val)). In standard JavaScript, in checks if an index exists as a property:
let arr = [10, 20, 30]
log(20 in arr) // => true (JavaScript checks for index "20" and returns false)
log(5 in arr) // => false (JavaScript checks for index "5" and returns false)
For objects, in works the same as in JavaScript - checks if a key exists as a property.
typeof operator
typeof parses with primary precedence (like a function call). Use parentheses when applying it to the result of a method call:
log(typeof 42) // => number
// typeof x.toString() - may not work as expected
// typeof(x.toString()) - use this form instead
The new keyword
new works with user-defined classes and with any built-in that has a .create() factory: error constructors, Date, RegExp, Set, Map, Promise and the Java-style classes (see JS: Built-in Globals). new X(...) is the same as X.create(...):
// Both forms are equivalent:
const d1 = new Date(2024, 0, 15)
const d2 = Date.create(2024, 0, 15)
const s1 = new Set([1, 2, 3])
const s2 = Set.create([1, 2, 3])
instanceof behavior
Works with user-defined classes (including inheritance chains), error types, wrapper types (Date, RegExp, Set, Map), and Array.
C-style for loop scope
for (let i = ...) creates a fresh binding per iteration, as in standard JS. Closures created inside the loop capture the value of their own iteration:
const fns = []
for (let i = 0; i < 3; i++) {
fns.push(() => i)
}
log(fns[0]()) // => 0
log(fns[1]()) // => 1
arguments in Arrow Functions
In the engine, all functions (including arrow functions) receive their own arguments object. In standard JavaScript, arrow functions do not have their own arguments.
const fn = () => arguments.length
log(fn(1, 2, 3)) // => 3 (in JS this would reference outer arguments or throw)
decodeURI / decodeURIComponent Error Handling
In standard JavaScript, these functions throw URIError on invalid input. In the engine, they return undefined instead:
log(decodeURIComponent("%ZZ")) // => undefined (JavaScript throws URIError)
log(decodeURI("%ZZ")) // => undefined (JavaScript throws URIError)
Undeclared variables and temporal dead zone
Reading a name that was never declared, or a let / const name before its declaration, returns undefined instead of throwing ReferenceError:
log(notDeclared) // => undefined (JavaScript throws ReferenceError)
log(y) // => undefined (JavaScript throws ReferenceError)
let y = 1
Property access on null / undefined
Reading a property of null or undefined returns undefined instead of throwing TypeError. Calling a method on null / undefined still throws an error:
let o = null
log(o.name) // => undefined (JavaScript throws TypeError)
let u
log(u.a.b) // => undefined
// o.foo() // Error: Cannot call method 'foo' on object
Arithmetic coercion
When neither operand of + is a string, both are converted to numbers, and a value that does not convert (NaN) counts as 0. The same applies to -, *, ** and the bitwise operators. / and % keep standard NaN results:
log(undefined + 1) // => 1 (JavaScript: NaN)
log("abc" - 1) // => -1 (JavaScript: NaN)
log([1] + [2]) // => 0 (JavaScript: "12")
log("abc" / 2) // => NaN
log("5" + 2) // => 52 (string concatenation, as in JavaScript)
Not supported
The following JavaScript features are not available:
- Generators (
function*,yield) import/export- Symbols
- WeakMap / WeakSet
- Proxy / Reflect
withstatement
Method whitelisting
Only methods listed in Type Methods are callable. Any other method throws a security error.
Additional features (not in standard JS)
The engine adds features not found in standard JavaScript:
- Range operators (
a..b,a..<b) - for iteration and slicing - Regex match operators (
=~,==~) - pattern matching - Typed catch (
catch (TypeError e)) - catch specific error types - Multi-catch (
catch (TypeError | RangeError e)) - Auto-await - promises automatically resolved
String.format()- Java-style formatting
Comments and semicolons
Both work the same as in JavaScript:
// Single-line comment
/* Multi-line comment */
let a = 1; // semicolons optional
let b = 2
Next steps
- JS: Language Basics - Core language features
- JS: Type Methods - Available whitelisted methods
- JS: Built-in Globals - Math, JSON, Object, Date, Java-style classes and more
- Limits - Resource constraints
- Scripting Language - Overview and sandbox details
