Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

change value of key in array of objects javascript

const users = [
  { name: "Alex", age: 25 },
  { name: "John", age: 32 },
];

const newUsers = users.map((user) => ({
  ...user,
  age: user.age + 5, // just for example
}));

// newUsers = [
// {name:"Alex" , age:30},
// {name:"John , age:37}
// ]
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #change #key #array #objects #javascript
ADD COMMENT
Topic
Name
9+7 =