Answers for "add key value pair to all objects in array"

0

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);
Posted by: Guest on October-07-2020

Code answers related to "add key value pair to all objects in array"

Code answers related to "TypeScript"

Browse Popular Code Answers by Language