Answers for "how to make use of map function with object"

24

.map for object javscript

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
0

map array method create object

var arr = [{
  id: 1,
  name: 'bill'
}, {
  id: 2,
  name: 'ted'
}]

var result = arr.map(person => ({ value: person.id, text: person.name }));
console.log(result)
 Run code snippetHide results
Posted by: Guest on April-25-2022

Code answers related to "how to make use of map function with object"

Code answers related to "Javascript"

Browse Popular Code Answers by Language