问题:
I need to store some statistics using JavaScript in a way like I'd do it in C#: 我需要使用JavaScript来存储一些统计信息,就像在C#中那样:
Dictionary<string, int> statistics;
statistics["Foo"] = 10;
statistics["Goo"] = statistics["Goo"] + 1;
statistics.Add("Zoo", 1);
Is there an Hashtable
or something like Dictionary<TKey, TValue>
in JavaScript? JavaScript中是否有Hashtable
或类似Dictionary<TKey, TValue>
类的东西?
How could I store values in such a way? 如何以这种方式存储值?
解决方案:
参考一: https://stackoom.com/question/54JS/如何在JavaScript中进行关联数组-哈希参考二: https://oldbug.net/q/54JS/How-to-do-associative-array-hashing-in-JavaScript
来源:oschina
链接:https://my.oschina.net/stackoom/blog/4284552