object object javascript map code example
Example 1: javascript map
const numbers = [0,1,2,3];
console.log(numbers.map((number) => {
return number;
}));
Example 2: map in javascript
let myMap = new Map()
let keyString = 'a string'
let keyObj = {}
// setting the values
myMap.set(keyString, "value associated with 'a string'")
myMap.set(keyObj, 'value associated with keyObj')
myMap.set(keyFunc, 'value associated with keyFunc')
myMap.size // 3
// getting the values
myMap.get(keyString) // "value associated with 'a string'"
myMap.get(keyObj) // "value associated with keyObj"
myMap.get(keyFunc) // "value associated with keyFunc"