0๐
โ
If you use ES6, you can do one liner like that:
var users = [
{ name: 'John', age: 25 },
{ name: 'Jane', age: 28 }
];
users.map(user => user.edit = false);
0๐
Use map and spread operator
const users = [
{ name: 'John', age: 25 },
{ name: 'Jane', age: 28 }
];
const usersUpdated = users.map(user => ({ ...user, edit: false }));
Source:stackexchange.com