Set and Map javascript code example
Example 1: map object and add new property javascript
Results.map(obj=> ({ ...obj, Active: 'false' }))
Example 2: append to map javascript
var myMap = {};
myMap[newKey] = newValue;
var myMap = new Map()
myMap.set("key0","value")
myMap.has("key1");
Example 3: map javascript
var numbers = [1, 4, 9];
var doubles = numbers.map(function(num) {
return num * 2;
});
Example 4: map in javascript
const arr = [1,2,3,4]
const sqrs = arr.map((num) => num ** 2)
console.log(sqrs)
console.log(arr)