Add property to an array of objects Add property to an array of objects arrays arrays

Add property to an array of objects


or use map

Results.map(obj=> ({ ...obj, Active: 'false' }))

Edited to reflect comment by @adrianolsk to not mutate the original and instead return a new object for each.

Read the spec


You can use the forEach method to execute a provided function once for each element in the array. In this provided function you can add the Active property to the element.

Results.forEach(function (element) {  element.Active = "false";});


With ES6 you can simply do:

 for(const element of Results) {      element.Active = "false"; }