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
,SQRT2
Math
个方法:ES6:
abs
,acos
,acosh
,asin
,asinh
,atan
,atan2
,atanh
,cbrt
,ceil
,clz32
,cos
,cosh
,exp
,expm1
,floor
,fround
,hypot
,_ _21,_21,imul
min
,pow
,random
,round
,sign
,sin
,sinh
,sqrt
,tan
,tanh
,trunc
Number
个属性:ES6:
EPSILON
,MAX_SAFE_INTEGER
,MAX_VALUE
,MIN_SAFE_INTEGER
,MIN_VALUE
,NEGATIVE_INFINITY
,NaN
,POSITIVE_INFINITY
Number
个方法:ES6:
isFinite
,isInteger
,isNaN
,isSafeInteger
,parseFloat
,parseInt
Number
个实例方法:String
个方法:ES5.1:
fromCharCode
- ES6:
fromCodePoint
- ES6:
String
个实例方法:ES5.1:
charAt
,concat
,indexOf
>,lastIndexOf
,match
,replace
,search
,slice
,split
,substr
,substring
,toLowerCase
,trim
,toUpperCase
Object
个方法: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
,isFrozen
isSealed
,keys
,preventExtensions
,seal
Object
个实例方法:ES5.1:
hasOwnProperty
,isPrototypeOf
,(0.3.0),propertyIsEnumerable
,toString
,valueOf
Array
个方法: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
,unshift
ES6:
copyWithin
(0.3.7),fill
,find
,findIndex
ES7:
includes
ArrayBuffer
个方法(0.3.8):ES6:
isView
ArrayBuffer
个实例方法(0.3.8):ES6:
slice
Typed-array
个构造函数(0.3.8):ES6:
Int8Array
,Uint8Array
,Uint8ClampedArray
,Int16Array
,Uint16Array
,Int32Array
,Uint32Array
,Float32Array
,Float64Array
Typed-array
个实例方法(0.3.8):ES6:
copyWithin
,fill
,join
,set
,slice
,sort
(0.4.2),subarray
,toString
Promise
个方法(0.3.8):ES6:
reject
,resolve
Promise
个实例方法(0.3.8):ES6:
catch
,finally
,then
Function
个实例方法:ES5.1:
apply
,bind
,call
RegExp
个实例方法:ES5.1:
exec
,test
,toString
RegExp
ES9 命名捕获组(0.3.2)Date
个方法:ES5.1:
now
,parse
,UTC
Date
个实例方法:ES5.1:
getDate
,getDay
,getFullYear
,getHours
,getMilliseconds
,getMinutes
,getMonth
,getSeconds
,getTime
,getTimezoneOffset
,getUTCDate
,getUTCDay
,getUTCFullYear
,getUTCHours
,getUTCMilliseconds
,getUTCMinutes
,getUTCMonth
,getUTCSeconds
,_ _21,toDateString
toTimeString
,toUTCString
,setDate
,setFullYear
,setHours
,setMinutes
,setMilliseconds
,setMonth
,setSeconds
,setTime
,setUTCDate
,setUTCFullYear
,setUTCHours
,setUTCMilliseconds
,setUTCMinutes
,setUTCMonth
,setUTCSeconds
JSON
个方法:ES5.1:
parse
stringify
ES5.1
arguments
对象(0.2.5)ES6 其余参数语法(不支持解构)(0.2.7)
ES5.1 全局功能:
decodeURI
,decodeURIComponent
,encodeURI
,encodeURIComponent
,isFinite
,isNaN
,parseFloat
,parseInt
Error
个对象:Error
,EvalError
,InternalError
,RangeError
,ReferenceError
,SyntaxError
,TypeError
,URIError
File 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.promises
API(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),