ECMAScript2022가 발표되었다. 주요 추가사항을 간단히 정리해본다.
//예시
class ClassWithPrivateSlot {
#privateSlot = true;
static hasPrivateSlot(obj) {
return #privateSlot in obj;
}
}
let arr = [a, b, c, d]
//기존문법
arr[0] // a
arr[2] // c
//추가된문법
arr.at(0) // a
arr.at(-1) // d
//변경전
(async function () {
await anyFunction()
})()
//변경후
await anyFunction()
try {
// Do something
} catch (otherError) {
throw new Error('Something went wrong', {cause: otherError});
}