update map value javascript 1

update map value javascript

var myMap = {};

myMap[newKey] = newValue;

// ...


// Another method

var myMap = new Map()
myMap.set("key0","value")
// ...
myMap.has("key1"); // evaluates to false, assuming key1 wasn't set

Here is what the above code is Doing:
1. We create a new Map object called myMap.
2. We add a key-value pair to myMap using the set() method.
3. We check if myMap has a key called key1 using the has() method.

Similar Posts