javascript create map code example
Example 1: javascript map
array.map((item) => {
return item * 2
}
Example 2: initialize a map js
let map = new Map()
map['bla'] = 'blaa'
map['bla2'] = 'blaaa2'
console.log(map)
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: javascript map
The map() method creates a new array with the results of calling a provided function on every element in the calling array.