Compatibility

njs 是根据ECMAScript 5.1(严格模式)和某些ECMAScript 6及更高版本的 extensions 创建的。合规性还在不断 Developing。

可以在Reference中找到不符合 ECMAScript 的 njs 特定属性和方法的定义。可以在ECMAScript specification中找到与 ECMAScript 兼容的 njs 属性和方法的定义。

目前支持什么

  • 布尔值,数字,字符串,对象,数组,函数,函数构造函数(0.3.6)和正则表达式

  • ES5.1 运算符,ES7 指数运算符

  • ES5.1 语句:breakcatchcontinuedo whileelsefinallyforfor inifreturnswitchthrowtryvarwhile,带标记的语句(0.2.8)

  • Math个属性:

  • ES6:ELN10LN2LOG10ELOG2EPISQRT1_2SQRT2

  • Math个方法:

  • ES6:absacosacoshasinasinhatanatan2atanhcbrtceilclz32coscoshexpexpm1floorfroundhypot,_ _21,_21,imul minpowrandomroundsignsinsinhsqrttantanhtrunc

  • Number个属性:

  • ES6:EPSILONMAX_SAFE_INTEGERMAX_VALUEMIN_SAFE_INTEGERMIN_VALUENEGATIVE_INFINITYNaNPOSITIVE_INFINITY

  • Number个方法:

  • ES6:isFiniteisIntegerisNaNisSafeIntegerparseFloatparseInt

  • Number个实例方法:

  • ES6:toExponential(0.3.6),toFixed(0.3.6),toPrecision(0.3.6)

  • String个方法:

  • ES5.1:fromCharCode

    • ES6:fromCodePoint
  • String个实例方法:

  • ES5.1:charAtconcatindexOf>,lastIndexOfmatchreplacesearchslicesplitsubstrsubstringtoLowerCasetrimtoUpperCase

  • Object个方法:

  • ES5.1:create(不带属性列表的支持),defineProperties(自0.3.3以来支持访问 Descriptors),defineProperty(自0.3.3以来支持访问 Descriptors),freezegetOwnPropertyDescriptorgetOwnPropertyDescriptors(0.3.1),getOwnPropertyNames(0.3.1),getPrototypeOfisExtensibleisFrozen isSealedkeyspreventExtensionsseal

  • Object个实例方法:

  • ES5.1:hasOwnPropertyisPrototypeOf,(0.3.0),propertyIsEnumerabletoStringvalueOf

  • Array个方法:

  • ES5.1:isArray

    • ES6:of
  • Array个实例方法:

  • ES5.1:concateveryfilterforEachindexOfjoinlastIndexOfmappoppushreducereduceRightreverseshiftslicesomesortspliceunshift

    • ES6:copyWithin(0.3.7),fillfindfindIndex

    • ES7:includes

  • ArrayBuffer个方法(0.3.8):

  • ES6:isView

  • ArrayBuffer个实例方法(0.3.8):

  • ES6:slice

  • Typed-array个构造函数(0.3.8):

  • ES6:Int8ArrayUint8ArrayUint8ClampedArrayInt16ArrayUint16ArrayInt32ArrayUint32ArrayFloat32ArrayFloat64Array

  • Typed-array个实例方法(0.3.8):

  • ES6:copyWithinfilljoinsetslicesort(0.4.2),subarraytoString

  • Promise个方法(0.3.8):

  • ES6:rejectresolve

  • Promise个实例方法(0.3.8):

  • ES6:catchfinallythen

  • Function个实例方法:

  • ES5.1:applybindcall

  • RegExp个实例方法:

  • ES5.1:exectesttoString

  • RegExp ES9 命名捕获组(0.3.2)

  • Date个方法:

  • ES5.1:nowparseUTC

  • Date个实例方法:

  • ES5.1:getDategetDaygetFullYeargetHoursgetMillisecondsgetMinutesgetMonthgetSecondsgetTimegetTimezoneOffsetgetUTCDategetUTCDaygetUTCFullYeargetUTCHoursgetUTCMillisecondsgetUTCMinutesgetUTCMonthgetUTCSeconds,_ _21,toDateString toTimeStringtoUTCStringsetDatesetFullYearsetHourssetMinutessetMillisecondssetMonthsetSecondssetTimesetUTCDatesetUTCFullYearsetUTCHourssetUTCMillisecondssetUTCMinutessetUTCMonthsetUTCSeconds

  • JSON个方法:

  • ES5.1:parse stringify

  • ES5.1 arguments对象(0.2.5)

  • ES6 其余参数语法(不支持解构)(0.2.7)

  • ES5.1 全局功能:decodeURIdecodeURIComponentencodeURIencodeURIComponentisFiniteisNaNparseFloatparseInt

  • Error个对象:ErrorEvalErrorInternalErrorRangeErrorReferenceErrorSyntaxErrorTypeErrorURIError

  • clearTimeoutsetTimeout函数(0.2.0)

  • File system个方法:fs.accessSync(0.3.9),fs.appendFileSyncfs.mkdirSync(0.4.2),fs.readdirSync(0.4.2),fs.readFileSyncfs.realpathSync(0.3.9),fs.renameSync(0.3.4),fs.rmdirSync(0.4.2),fs.symlinkSync(0.3.9)

  • fs.promises API(0.3.9),文件系统方法的异步版本。

  • Crypto个方法(0.2.0):crypto.createHashcrypto.createHmac

  • ES6 模块支持:默认export和默认import语句(0.3.0)

  • ES6 箭头功能(0.3.1)

  • 模板文字:多行字符串,表达式插值,嵌套模板(0.3.2)

  • 全局对象(0.3.3):

  • globalThis别名(0.3.8),