Compatibility

What is currently supported
What is not supported yet

njs is created in compliance with ECMAScript 5.1 (strict mode) with some ECMAScript 6 and later extensions. The compliance is still evolving.

What is currently supported

  • Boolean values, numbers, strings, objects, arrays, functions, and regular expressions
  • ES5.1 operators, ES7 exponentiation operators
  • ES5.1 statements: var , if , else , switch , for , for in , while , do while , break , continue , return , try , catch , throw , finally
  • ES6 Number and Math properties and methods
  • String methods:
    • ES5.1: fromCharCode , concat , slice , substring , substr , charAt , charCodeAt , indexOf , lastIndexOf , toLowerCase , toUpperCase , trim , search , match , split , replace
    • ES6: fromCodePoint , codePointAt , includes , startsWith , endsWith , repeat
    • non-standard: bytesFrom (0.2.3) fromUTF8 , toUTF8 , fromBytes , toBytes
  • Object methods:
    • ES5.1: create (support without properties list), keys , defineProperty , defineProperties , getOwnPropertyDescriptor , getPrototypeOf , hasOwnProperty , isPrototypeOf , preventExtensions , isExtensible , freeze , isFrozen , seal , isSealed
  • Array methods:
    • ES5.1: isArray , slice , splice , push , pop , unshift , shift , reverse , sort , join , concat , indexOf , lastIndexOf , forEach , some , every , filter , map , reduce , reduceRight
    • ES6: of , fill , find , findIndex
    • ES7: includes
  • ES5.1 Function methods: call , apply , bind
  • ES5.1 RegExp methods: test , exec
  • ES5.1 Date methods
  • ES5.1 JSON object
  • ES5.1 global functions: isFinite , isNaN , parseFloat , parseInt , decodeURI , decodeURIComponent , encodeURI , encodeURIComponent
  • Error objects: Error , EvalError , InternalError , RangeError , ReferenceError , SyntaxError , TypeError , URIError
  • setTimeout() and clearTimeout() functions (0.2.0)
  • Node.js style File system methods: fs.readFile , fs.readFileSync , fs.appendFile , fs.appendFileSync , fs.writeFile , fs.writeFileSync
  • Node.js style Crypto methods (0.2.0): crypto.createHash , crypto.createHmac

What is not supported yet

  • ES6 let and const declarations
  • labels
  • arguments array
  • eval function
  • new Function() constructor
  • setInterval , setImmediate functions
  • non-integer fractions ( .235 )