js new 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: map in javascript
const arr = [1,2,3,4]
const sqrs = arr.map((num) => num ** 2)
console.log(sqrs)
console.log(arr)
Example 4: 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 5: map in js
const data = {name: "laptop", brands: ["dell", "acer", "asus"]}
let inside_data = data.brands.map((i) => {
console.log(i);
});
Example 6: map in javascript
['elem', 'another', 'name'].map((value, index, originalArray) => {
console.log(.....)
});