javascript string map code example
Example 1: js map constructor
let myMap = new Map([
[1, 'one'],
[2, 'two'],
[3, 'three'],
])
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: map in javascript
['elem', 'another', 'name'].map((value, index, originalArray) => {
console.log(.....)
});