I'm trying to delete a known key from a Javascript object. I've created a tiny reproduction here, and the result is the same when compared to a much larger object. I'm assigning an object to a new variable, and want to delete the key from the new variable without changing the original variable, but that's not working.
The original key is also getting deleted which isn't correct, what do I need to change to prevent this?
const person = {
name: 'john',
age: 50
}
const newPerson = person
delete newPerson.name
console.log(person) <-- contains only name, I expect name and age since I'm only deleting from newly created newPerson variable