you never set d[a] to any value.
Because of this, d[a] evaluates to undefined , and you cannot set properties to undefined .
If you add d[a] = {} immediately after d = {} , everything should work as expected.
Alternatively, you can use the object initializer:
d[a] = { greetings: b, data: c };
Or you can set all the properties of d in an instance of an anonymous function:
d = new function () { this[a] = { greetings: b, data: c }; };
If you are in an environment that supports ES2015 features, you can use the names of the calculated properties :
d = { [a]: { greetings: b, data: c } };
zzzzBov Sep 20 '11 at 2:45 2011-09-20 02:45
source share