change object name javascript code example
Example 1: js rename property
function renameProperty(obj, oldName, newName) {
obj[newName] = obj[oldName];
delete obj[oldName];
}
Example 2: js change value in object
var object = { boo:true, baa:5 };
console.log(object);
function change() {
object.boo = false;
object.baa++;
};
change();
console.log(object);
//Hope this helps!
Example 3: js rename property
obj.newProperty = obj.property
delete obj.property