56
rated 0 times
[
62]
[
6]
/ answers: 1 / hits: 41578
/ 6 Years ago, wed, march 14, 2018, 12:00:00
I have JSON array like this
var array= [{id:1,name:'foo'},{id:2,name:'bar'}]
I would like to add a new key (eg:isApproved
) to each object in the existing array
expected output:
var array= [{id:1,name:'foo',isApproved:true},{id:2,name:'bar',isApproved:true}]
I used the map function to achieve this
array.map(function(e,index){
e.isApproved[index]= true
}
But this not worked for me
More From » arrays