js create map code example

Example 1: javascript map

array.map((item) => {
  return item * 2
} // an example that will map through a a list of items and return a new array with the item multiplied by 2

Example 2: initialize a map js

let map = new Map()
map['bla'] = 'blaa'
map['bla2'] = 'blaaa2'

console.log(map)  // Map { bla: 'blaa', bla2: 'blaaa2' }

Example 3: new map js

let utilisateurs = new Map()

utilisateurs.set('Mark Zuckerberg' ,{
    email: '[email protected]',
    poste: 'PDG',
})

utilisateurs.set ('bill Gates',{
    email: '[email protected]' ,
    poste : 'sauver le monde' ,

})
    
console.log(utilisateurs);

Example 4: map in javascript

['elem', 'another', 'name'].map((value, index, originalArray) => { 
  console.log(.....)
});

Example 5: how to create an element in js using the map method

const numbers = [1, 2, 3, 4, 5]; 

const bigNumbers = numbers.map(number => {
  return number * 10;
});

Tags:

Cpp Example