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}
// ]
let arrayObj = [{key1:'value1', key2:'value2'},{key1:'value1', key2:'value2'}];
arrayObj = arrayObj.map(item => {
return {
stroke: item.key1,
key2: item.key2
};
});
const arrayOfObj = [{
key1: 'value1',
key2: 'value2'
}, {
key1: 'value1',
key2: 'value2'
}];
const newArrayOfObj = arrayOfObj.map(({
key1: stroke,
...rest
}) => ({
stroke,
...rest
}));
console.log(newArrayOfObj);