Skip to content

Instantly share code, notes, and snippets.

@TimLang
Created March 19, 2014 07:06
Show Gist options
  • Save TimLang/9636789 to your computer and use it in GitHub Desktop.
Save TimLang/9636789 to your computer and use it in GitHub Desktop.
javascript rename property
Object.prototype.renameProperty = function (oldName, newName) {
if (this.hasOwnProperty(oldName)) {
this[newName] = this[oldName];
delete this[oldName];
}
return this;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment