Created
December 21, 2015 22:46
-
-
Save pgarciacamou/b734eb38e290b9a6dd3e to your computer and use it in GitHub Desktop.
Recursive Object Cloning (shallow).
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){ | |
if(!(o instanceof Object)) return o; | |
var obj = {}; | |
for(var prop in o) { | |
if(o.hasOwnProperty(prop)) obj[prop] = clone(o[prop]); | |
} | |
return obj; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment