Skip to content

Instantly share code, notes, and snippets.

@Raynos
Created November 30, 2011 21:09
Show Gist options
  • Select an option

  • Save Raynos/1410832 to your computer and use it in GitHub Desktop.

Select an option

Save Raynos/1410832 to your computer and use it in GitHub Desktop.
simple clone
function clone(o) {
var pds = {};
Object.getOwnPropertyNames(o).forEach(function _eachName(name) {
pds[name] = Object.getOwnPropertyDescriptor(o, name);
});
return Object.create(Object.getPrototypeOf(o), pds);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment