Skip to content

Instantly share code, notes, and snippets.

@pgarciacamou
Created December 21, 2015 22:46
Show Gist options
  • Save pgarciacamou/b734eb38e290b9a6dd3e to your computer and use it in GitHub Desktop.
Save pgarciacamou/b734eb38e290b9a6dd3e to your computer and use it in GitHub Desktop.
Recursive Object Cloning (shallow).
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