Reputation: 197
I have a problem about how to change object properties name. I have a object like this:
description: "Human Resource Management Module"
id: 8
route: "/apps"
__children: Array(2)
How can i change __children
properties name to indexSearch
?
Upvotes: 0
Views: 6794
Reputation: 38171
I assume you are looking for solution to change object properties programmatically. you can assign the value of old property(__children
) to a new one(indexSearch
) and then delete the old property.
obj['indexSearch'] = obj['__children'];
delete obj['__children'];
see the below example.
var obj = {
description: "Human Resource Management Module",
id: 8,
route: "/apps",
__children: ['item1', 'item2']
};
console.log(obj)
obj['indexSearch'] = obj['__children'];
delete obj['__children'];
console.log(obj)
Upvotes: 5
Reputation: 13807
You can rename it like this, it's pretty simple:
You will have to use the keyboard, potentially the mouse as well.
Upvotes: -3