Skip to content

Instantly share code, notes, and snippets.

@dtsn
Created October 19, 2012 10:11
Show Gist options
  • Save dtsn/3917305 to your computer and use it in GitHub Desktop.
Save dtsn/3917305 to your computer and use it in GitHub Desktop.
JavaScript Shallow Clone
Object.prototype.clone = function () {
var obj = {};
for (var prop in this) {
obj[prop] = this[prop];
}
return obj;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment