Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR TYPESCRIPT

add key value pair to all objects in array

var arrOfObj = [{
  name: 'eve'
}, {
  name: 'john'
}, {
  name: 'jane'
}];

var result = arrOfObj.map(function(el) {
  var o = Object.assign({}, el);
  o.isActive = true;
  return o;
})

console.log(arrOfObj);
console.log(result);
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #add #key #pair #objects #array
ADD COMMENT
Topic
Name
9+6 =