1/*
2Computed Property Names is ES6 feature which allows
3the names of object properties in JavaScript OBJECT LITERAL NOTATION
4to be determined dynamically, i.e. computed.
5*/
6
7let propertyname = 'c';
8
9let obj ={
10 a : 11,
11 b : 12,
12 [propertyname] : 13
13};
14
15obj; // result is {a:11 , b:12 , c:13}
16
17//or incase if you want a as your object you can set in this way
18
19let a_value = {
20 [obj.a] = obj // a_value's key name as (a) and the complete (obj) present above itself will act as a value
21};
22
1/*
2Computed Property Names is ES6 feature which allows
3the names of object properties in JavaScript OBJECT LITERAL NOTATION
4to be determined dynamically, i.e. computed.
5*/
6
7let propertyname = 'c';
8
9let obj ={
10 a : 11,
11 b : 12,
12 [propertyname] : 13
13};
14
15obj; // result is {a:11 , b:12 , c:13}
16
17//or incase if you want a as your object you can set in this way
18
19let a_value = {
20 [obj.a] = obj // a_value's key name as (a) and the complete (obj) present above itself will act as a value
21};