es789新特性
es7:
-
Array.prototype.includes()
-
指数操作符
指数运算符**,**具有与Math.pow(…)等效的计算结果
console.log(Math.pow(2, 10)); // 输出1024
console.log(2**10);// 输出1024
es8:
-
async/await
-
Object.values()
-
Object.entries()
-
String padding
-
函数参数列表结尾允许逗号
-
Object.getOwnPropertyDescriptors()
用来获取一个对象的所有自身属性的描述符,如果没有任何自身属性,则返回空对象。
const obj = {
a: 'a',
get b() { return 'b' }
};
Object.getOwnPropertyDescriptors(obj2)
// {
// b: {
// configurable: true,
// enumerable: true,
// get: function b(){},
// set: undefined
// },
// a: {
// configurable: true,
// enumerable: true,
// value: "a",
// writable: true
// }
// }
-
SharedArrayBuffer对象
-
Atomics对象
es9
- 异步迭代(async/await for “for of”)
async function process(array) {
for await (let i of array) {
doSomething(i);
}
}
-
Promise.finally()
-
Rest/Spread 属性 (for Object)
-
正则表达式命名捕获组
-
正则表达式反向断言
-
正则表达式dotAll模式
-
非转义序列的模板字符串
es10
-
行分隔符(U + 2028)和段分隔符(U + 2029)符号现在允许在字符串文字中,与JSON匹配
-
更加友好的 JSON.stringify
-
新增了Array的flat()方法和flatMap()方法
-
新增了String的trimStart()方法和trimEnd()方法
-
Object.fromEntries()
-
Symbol.prototype.description
-
String.prototype.matchAll
-
Function.prototype.toString()现在返回精确字符,包括空格和注释
-
修改 catch 绑定
try {} catch {}
-
新的基本数据类型BigInt