new map js code example
Example 1: initialize a map js
let map = new Map()
map['bla'] = 'blaa'
map['bla2'] = 'blaaa2'
console.log(map)
Example 2: map in js
const data = {name: "laptop", brands: ["dell", "acer", "asus"]}
let inside_data = data.brands.map((i) => {
console.log(i);
});
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
const array1 = [1, 4, 9, 16];
const map1 = array1.map(x => x * 2);
console.log(map1);
Example 5: javascript map ket to value
m.set('color', 'red')
m.set('age', 2)