코라제이 2020. 1. 8. 18:54

객체에서 key값을 [] 감싸면 그 안에 있는 값이 실제 key값이 된다

 

const key = 'keyName';
const foo = { [key]: 1}; // {keyName: 1}