map js object code example
Example 1: map object es6
var myObject = { 'a': 1, 'b': 2, 'c': 3 };
Object.keys(myObject).map(function(key, index) {
myObject[key] *= 2;
});
console.log(myObject);
Example 2: javascript map
array.map((item) => {
return item * 2
}
Example 3: initialize a map js
let map = new Map()
map['bla'] = 'blaa'
map['bla2'] = 'blaaa2'
console.log(map)
Example 4: javascript map to object
Object.fromEntries(Map)
Example 5: 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 6: javascript map
The map() method creates a new array with the results of calling a provided function on every element in the calling array.