我正在尝试在Javascript中创建一些动态哈希
我有
Postcodes = ["one", "two"]
由此我尝试创建一个哈希,其中哈希的键是数组中的值。
postcode_1 = Postcodes[0]
postcode_2 = Postcodes[1]
postcode1 = {}
postcode2 = {}
postcode1[postcode_1] = {foo: 1200, bar: "woo"};
postcode2[postcode_2] = {foo: 1200, bar: "woo"};
这不起作用我最终需要的是一个看起来像这样的哈希
{"one": {foo: 1200, bar: "woo"}