Sets the value for the key in the Map object.
set(key, value)
key
The key of the element to add to the Map object. May be any JavaScript type, including objects. If the value with the key exists, it will be updated to the new value.
value
The value of the element. May be any JavaScript type, including objects.
The same Map object.
const map = new Map()
map.set("myKey", "myValue")
map.get("myKey")
"myValue"
const map = new Map()
map.set("one", 1).set("two", 2).set("three", 3)
map.get("two")
2