function one(data) {
someotherfunction({
data.id: {
name: data.nm,
age: data.age
});
}
one({ id: 2, name: "Stack", age: "20" });
Why can't I set data.id
as the property name of that sub-object? I tried many ways of setting the id but it only works if I set it to some string name....
var i = data.id;
someotherfunction({i:{name:data.nm,age:data.age});
It doesn't recognize the variable either?