Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

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)
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #javascript #create #array #objects #map
ADD COMMENT
Topic
Name
9+2 =