Set up a map in js using json
- 2020-03-30 02:46:14
- OfStack
How to set up a map (actually using a json implementation)
Since it's a map, there's a way to retrieve whether a key exists or not
A simple one-sentence way to declare the key and value in the map:
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'}