change key in objects js code example
Example 1: js rename property
function renameProperty(obj, oldName, newName) {
obj[newName] = obj[oldName];
delete obj[oldName];
}
Example 2: js rename property
obj.newProperty = obj.property
delete obj.property