Answers for "js object map"

13

map through keys javascript

var myObject = { 'a': 1, 'b': 2, 'c': 3 };

Object.keys(myObject).map(function(key, index) {
  myObject[key] *= 2;
});

console.log(myObject);
// => { 'a': 2, 'b': 4, 'c': 6 }
Posted by: Guest on July-30-2020
5

javascript iterate object key values

Object.entries(obj).forEach(([key, value]) => {
	console.log(key, value);
});
Posted by: Guest on March-30-2020
2

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);
Posted by: Guest on March-17-2020
2

object to map javascript

const map = new Map(Object.entries({foo: 'bar'}));

map.get('foo'); // 'bar'
Posted by: Guest on March-02-2021
1

javascript map to object

Object.fromEntries(Map)
Posted by: Guest on March-17-2021
0

map to object

let map = new Map();
map.set("a", 1);
map.set("b", 2);
map.set("c", 3);

let obj = Array.from(map).reduce((obj, [key, value]) => (
  Object.assign(obj, { [key]: value }) // Be careful! Maps can have non-String keys; object literals can't.
), {});

console.log(obj); // => { a: 1, b: 2, c: 3 }
Posted by: Guest on July-04-2021

Code answers related to "Javascript"

Browse Popular Code Answers by Language