Methods to Create new map
call Map()
to create new empty map
const emptyMap = new Map();
call Map()
with Array of [arrays with key-value pairs]
const map = new Map([
[1, "one"],
[2, "two"],
[3, "three"]
])
call Map()
& chain Set()
to add entries
const map = new Map()
.set(1, "one")
.set(2, "two")
.set(3, "three")