Sometimes, we want to change property name with JavaScript.
In this article, we’ll look at how to change property name with JavaScript.
How to change property name with JavaScript?
To change property name with JavaScript, we use the delete operator.
For instance, we write
a.prop3 = a.prop1;
delete a.prop1;
to assign a.prop1 to a.prop3.
Then we remove a.prop1 from a with delete.
Conclusion
To change property name with JavaScript, we use the delete operator.