Answers for "map to array of objects javascript"

2

javascript create array of objects with map

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

var result = arr.map(person => ({ value: person.id, text: person.name }));
console.log(result)
Posted by: Guest on December-31-2020
7

how to use the map method in javascript

const numbers = [1, 2, 3, 4, 5]; 

const bigNumbers = numbers.map(number => {
  return number * 10;
});
Posted by: Guest on April-08-2020
0

map a property from array of objects javascript

var result = objArray.map(function(a) {return a.foo;});
Posted by: Guest on July-29-2020

Code answers related to "map to array of objects javascript"

Browse Popular Code Answers by Language