Set up a map in js using json


How to set up a map (actually using a json implementation)


var a = {};
a["key1"] = "value1";
a["key2"] = "value2";

Since it’s a map, there’s a way to retrieve whether a key exists or not


if ("key1" in a) {
// something
} else {
// something else
}

A simple one-sentence way to declare the key and value in the map:


var a = {'key1': 'value1', 'key2': 'value2'}