My Tech Notes
Javascript: create a object property from a variable
Option 1:
const name = 'n'; let obj = {}; obj[name]=1;
Option 2(ES6):
const name = 'n'; let obj = { [name] : 1}
No comments:
Post a Comment
‹
›
Home
View web version
No comments:
Post a Comment