Created
November 30, 2011 21:09
-
-
Save Raynos/1410832 to your computer and use it in GitHub Desktop.
simple clone
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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