On this page
Compatibility
njs 是根据ECMAScript 5.1(严格模式)和某些ECMAScript 6及更高版本的 extensions 创建的。合规性还在不断 Developing。
可以在Reference中找到不符合 ECMAScript 的 njs 特定属性和方法的定义。可以在ECMAScript specification中找到与 ECMAScript 兼容的 njs 属性和方法的定义。
目前支持什么
布尔值,数字,字符串,对象,数组,函数,函数构造函数(0.3.6)和正则表达式
ES5.1 运算符,ES7 指数运算符
ES5.1 语句:
break,catch,continue,do while,else,finally,for,for in,if,return,switch,throw,try,var,while,带标记的语句(0.2.8)Math个属性:ES6:
E,LN10,LN2,LOG10E,LOG2E,PI,SQRT1_2,SQRT2Math个方法:ES6:
abs,acos,acosh,asin,asinh,atan,atan2,atanh,cbrt,ceil,clz32,cos,cosh,exp,expm1,floor,fround,hypot,_ _21,_21,imulmin,pow,random,round,sign,sin,sinh,sqrt,tan,tanh,truncNumber个属性:ES6:
EPSILON,MAX_SAFE_INTEGER,MAX_VALUE,MIN_SAFE_INTEGER,MIN_VALUE,NEGATIVE_INFINITY,NaN,POSITIVE_INFINITYNumber个方法:ES6:
isFinite,isInteger,isNaN,isSafeInteger,parseFloat,parseIntNumber个实例方法:String个方法:ES5.1:
fromCharCode- ES6:
fromCodePoint
- ES6:
String个实例方法:ES5.1:
charAt,concat,indexOf>,lastIndexOf,match,replace,search,slice,split,substr,substring,toLowerCase,trim,toUpperCaseObject个方法:ES5.1:
create(不带属性列表的支持),defineProperties(自0.3.3以来支持访问 Descriptors),defineProperty(自0.3.3以来支持访问 Descriptors),freeze,getOwnPropertyDescriptor,getOwnPropertyDescriptors(0.3.1),getOwnPropertyNames(0.3.1),getPrototypeOf,isExtensible,isFrozenisSealed,keys,preventExtensions,sealObject个实例方法:ES5.1:
hasOwnProperty,isPrototypeOf,(0.3.0),propertyIsEnumerable,toString,valueOfArray个方法:ES5.1:
isArray- ES6:
of
- ES6:
Array个实例方法:ES5.1:
concat,every,filter,forEach,indexOf,join,lastIndexOf,map,pop,push,reduce,reduceRight,reverse,shift,slice,some,sort,splice,unshiftES6:
copyWithin(0.3.7),fill,find,findIndexES7:
includes
ArrayBuffer个方法(0.3.8):ES6:
isViewArrayBuffer个实例方法(0.3.8):ES6:
sliceTyped-array个构造函数(0.3.8):ES6:
Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64ArrayTyped-array个实例方法(0.3.8):ES6:
copyWithin,fill,join,set,slice,sort(0.4.2),subarray,toStringPromise个方法(0.3.8):ES6:
reject,resolvePromise个实例方法(0.3.8):ES6:
catch,finally,thenFunction个实例方法:ES5.1:
apply,bind,callRegExp个实例方法:ES5.1:
exec,test,toStringRegExpES9 命名捕获组(0.3.2)Date个方法:ES5.1:
now,parse,UTCDate个实例方法:ES5.1:
getDate,getDay,getFullYear,getHours,getMilliseconds,getMinutes,getMonth,getSeconds,getTime,getTimezoneOffset,getUTCDate,getUTCDay,getUTCFullYear,getUTCHours,getUTCMilliseconds,getUTCMinutes,getUTCMonth,getUTCSeconds,_ _21,toDateStringtoTimeString,toUTCString,setDate,setFullYear,setHours,setMinutes,setMilliseconds,setMonth,setSeconds,setTime,setUTCDate,setUTCFullYear,setUTCHours,setUTCMilliseconds,setUTCMinutes,setUTCMonth,setUTCSecondsJSON个方法:ES5.1:
parsestringifyES5.1
arguments对象(0.2.5)ES6 其余参数语法(不支持解构)(0.2.7)
ES5.1 全局功能:
decodeURI,decodeURIComponent,encodeURI,encodeURIComponent,isFinite,isNaN,parseFloat,parseIntError个对象:Error,EvalError,InternalError,RangeError,ReferenceError,SyntaxError,TypeError,URIErrorFile system个方法:fs.accessSync(0.3.9),fs.appendFileSync,fs.mkdirSync(0.4.2),fs.readdirSync(0.4.2),fs.readFileSync,fs.realpathSync(0.3.9),fs.renameSync(0.3.4),fs.rmdirSync(0.4.2),fs.symlinkSync(0.3.9)fs.promisesAPI(0.3.9),文件系统方法的异步版本。Crypto个方法(0.2.0):crypto.createHash,crypto.createHmacES6 模块支持:默认
export和默认import语句(0.3.0)ES6 箭头功能(0.3.1)
模板文字:多行字符串,表达式插值,嵌套模板(0.3.2)
全局对象(0.3.3):
globalThis别名(0.3.8),