ES2022
模块顶层await
#x
私有属性、私有方法
#x in obj
检查存在私有属性、方法
tc39/proposal-private-fields-in-in
class静态块
tc39/proposal-class-static-block
正则d
修饰符
tc39/proposal-regexp-match-indices
新增d
修饰符,可以让exec()
、match()
的返回结果添加indices
属性,在该属性上面可以拿到匹配的开始位置和结束位置。
js
const text = 'zabbcdef';
const re = /ab/d;
const result = re.exec(text);
result.index // 1
result.indices // [ [1, 3] ]
err.cause
js
const actual = new Error('an error!', { cause: 'Error cause' });
actual.cause; // 'Error cause'
str.at()
、arr.at()
tc39/proposal-relative-indexing-method
js
const sentence = 'This is a sample sentence'
sentence.at(0); // 'T'
sentence.at(-1); // 'e'
sentence.at(100) // undefined