◈ ES5新特性
ES5的新特性主要在扩展Object、Array、Function等内建对象的功能上,另外引入了strict mode 和 JSON对象等
♢ 对Object对象的扩展
Object.getPrototypeOf(o)
Object.getOwnPropertyDescriptor(o,p)
Object.getOwnPropertyNames(o)
Object.create(o,p)
Object.defineProperty(o,p,attrs)
Object.defineProperties(o,props)
Object.seal(o)
Object.freeze(o)
Object.preventExtensions(o)
Object.isSealed(o)
Object.isExtensible(o)
Object.keys(o)
Object.prototype.isPrototypeOf(v)
Object.prototype.isPrototypeOf(v)
复制代码
♢ 对Array的扩展
Array.isArray(a)
Array.prototype.indexOf(e,i)
Array.prototype.lastIndexOf(e,i)
Array.prototype.some(t,c)
Array.prototype.some(t,c)
Array.prototype.map(f,c)
Array.prototype.filter(f,c)
Array.prototype.reduceRight(r,v)
复制代码
♢ 对String的扩展
String.prototpye.trim()
复制代码
♢ 对Function的扩展
Function.prototype.bind(thisTarget, arg1,…argn)
复制代码
♢ JSON
JSON.parse(text)
JSON.stringify(obj)
复制代码
♢ 对Date的扩展
Date.now
Date.prototype.toISOString
复制代码
♢ 其他新增
- 放开了关键字不允许作为属性名的限制
- getter和setter函数
复制代码
参考:
◈ ES2016(ES7)新特性
- Array.prototype.includes()
- 指数运算符(**),与Math.pow(a, b) 功能一样,求a的b次幂
◈ ES2017(ES8)新特性
- Object.values()
- Object.entries()
- async 函数
- Object.getOwnPropertyDescriptors
- 在函数最后一个参数的末尾添加逗号
♢ 字符串新增方法
- padStart(): 如果某个字符串不够指定长度,会在头部补全
- padEnd():如果某个字符串不够指定长度,会在尾部补全
◈ ES2018(ES9)新特性
- Promise.prototype.finally()
- async函数里面可以使用异步循环
- 共享内存和原子特性
- 对象的Rest和Spread操作
♢ 正则的扩展
- 正则表达式中的‘.’匹配所有字符
- 正则表达式捕获Name Group
- 正则的lookbehind断言
- 正则Unicode属性转义符
参考: