javascript - How to add object literal within object literal -
this question has answer here:
assuming have object literal looks this:
c = {"a":"a","b":"b","c":"c"};
and want add object this..
"d" : {"e":e}
where e
variable. , e = "valueofe"
c
have kind of value..
c = {"a":"a","b":"b","c":"c", "d" : { "e" : "valueofe"}};
how that?
the values in object literals can arbitrary expressions, means can contain other object literals, make use of existing variables, , on; if you're asking think are, can write:
c = { "a": "a", "b": "b", "c": "c", "d": { "e": e } };
Comments
Post a Comment