Skip to content
导航

ES2022

模块顶层await

tc39/proposal-top-level-await

#x私有属性、私有方法

tc39/proposal-class-fields

#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

tc39/proposal-error-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

参考资料