I wanted to add a key:value parameter to all the objects in an array.
eg:
var arrOfObj = [{name: \'eve\'},{name:\'john\'},{name:\'jane\'}];
<
Simply use map function:
var arrOfObj = arrOfObj.map(function(element){
element.active = true;
return element;
}
Map is pretty decent on compatibility: you can be reasonably safe from IE <= 9.
However, if you are 100% sure your users will use ES6 Compatible browser, you can shorten that function with arrow functions, as @Sergey Panfilov has suggested.