Skip to content

Instantly share code, notes, and snippets.

@gecbla
Last active December 19, 2015 19:48
Show Gist options
  • Save gecbla/6008374 to your computer and use it in GitHub Desktop.
Save gecbla/6008374 to your computer and use it in GitHub Desktop.
Clone object in JavaScript - prototypal inheritance
/**
* @see http://javascript.crockford.com/prototypal.html
*/
if (typeof Object.create !== 'function') {
Object.create = function(o) {
var F = function() {};
F.prototype = o;
return new F();
};
}
newObj = Object.create(oldObj);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment