javascript map and set code example
Example 1: append to map javascript
var myMap = {};
myMap[newKey] = newValue;
var myMap = new Map()
myMap.set("key0","value")
myMap.has("key1");
Example 2: javascript map
const myArray = ['Sam', 'Alice', 'Nick', 'Matt'];
const newArray = myArray.map(name => {
return 'My name is ' + name;
});
console.log(newArray);
const anotherArray = myArray.map((value, index) => index + ": " + value);
console.log(anotherArray);
console.log(myArray);
Example 3: javascript map
const array1 = [1, 4, 9, 16];
const map1 = array1.map(x => x * 2);
console.log(map1);