I want to replace a variable in an object array with another name,
let arr={name:'ash', id:2}
I want to replace it as arr = {newname:'ash', id:2}
I want to replace a variable in an object array with another name,
let arr={name:'ash', id:2}
I want to replace it as arr = {newname:'ash', id:2}
2
Answers
There are two options:
1.
You can use
omit
function fromlodash
library, and this option is better. Here is docimentation of omit functionYou can use a variable to store the value of name ,then use Object operator delete the key of name