프로퍼티 접근: dot 표기법 사용
- Use dot notation when accessing properties.
- 속성에 접근할 때는 마침표를 사용한다.
eslint: dot-notation
const luke = {
jedi: true,
age: 28,
};
// bad
const isJedi = luke['jedi'];
// good
const isJedi = luke.jedi;
변수로 프로퍼티 접근 : [] 사용
- Use subscript notation
[ ]
when accessing properties with a variable.
- 변수를 사용해 프로퍼티에 억세스하는 경우는 대괄호
[ ]
를 사용한다.
const luke = {
jedi: true,
age: 28,
};
function getProp(prop) {
return luke[prop];
}
const isJedi = getProp('jedi');
지수 연산 : ** > Math.pow
- 제곱 계산을 할 때는 제곱 연산자 **을 사용한다.
eslint: no-restricted-properties.
// bad
const binary = Math.pow(2, 10);
// good
const binary = 2 ** 10;