我的代码:
var a = "1",
b = "hello",
c = { "100" : "some important data" },
d = {};
d[a]["greeting"] = b;
d[a]["data"] = c;
console.debug (d);
我收到以下错误:
Uncaught TypeError:无法设置未定义的属性“ greeting”。
我正在尝试做类似于关联数组的操作。为什么这不起作用?
1
d [a]未定义。本质上d [“ 1”]是不确定的
—
Joseph Marikle 2011年