2.2.3 객체 리터럴 변경사항
최신 ECMAScript에서의 객체 리터럴 변경사항에 대해 다룬다.
트레일링 콤마 (trailing comma)
const objWithTrailingComma = {
a: 1,
b: 1,
};단축 속성명 (shorthand property name)
const [a, b] = [1, 2];
const obj = { a: a, b: b };
const obj2 = { a, b }; // same as { a: a, b: b }단축 메소드명 (shorthand method name)
// old
const objWithFunction = {
f: function () { console.log(1); }
};
objWithFunction.f(); // 1
// new (ES6~ )
const objWithFunction2 = {
f() { console.log(1); }
};
objWithFunction2.f(); // 1계산된 속성 이름(computed property name)
Last updated