How to fill a Javascript object literal with many static key/value pairs efficiently?
问题 The typical way of creating a Javascript object is the following: var map = new Object(); map[myKey1] = myObj1; map[myKey2] = myObj2; I need to create such a map where both keys and values are Strings. I have a large but static set of pairs to add to the map. Is there any way to perform something like this in Javascript: var map = { { "aaa", "rrr" }, { "bbb", "ppp" } ... }; or do I have to perform something like this for each entry: map["aaa"]="rrr"; map["bbb"]="ppp"; ... Basically, remaining