I have an object array
const arr =
[
{ id: 1, name : "Joe", age:20, email: "[email protected]"},
{ id: 2, name : "Mike", age:50, email: "[email protected]"},
{ id: 3, name : "Joe", age:45, email: "[email protected]"}
]
How can I create a new array without modifying first one with only one property changed, like this (id is unique):
[
{ id: 1, name : "Joe", age:20, email: "[email protected]"},
{ id: 2, name : "Mike", age:50, email: "[email protected]"},
{ id: 3, name : "Harry", age:45, email: "[email protected]"}
]
Changed last element name property from "Joe" to "Harry"