I have an array of objects. I would like to deep copy the array of objects and make some changes to each object. I want to do this without modifying the original array or or
I prefer JSON.stringify and JSON.parse
var users = [ { id: 1, name: 'Jack', approved: false },
{ id: 2, name: 'Bill', approved: true },
{ id: 3, name: 'Rick', approved: false },
{ id: 4, name: 'Rick', approved: true } ];
// user2 will be copy of array users without reference
var users2 = JSON.parse(JSON.stringify(users));