Skip to content

Instantly share code, notes, and snippets.

@hughfdjackson
Created July 14, 2012 00:42
Show Gist options
  • Save hughfdjackson/3108502 to your computer and use it in GitHub Desktop.
Save hughfdjackson/3108502 to your computer and use it in GitHub Desktop.
deep clone
function deepClone(o) {
return (typeof o !== 'object' || o === null) ? o
: (o instanceof Array) ? o.map(deepClone)
: Object.keys(o).reduce(function (result, key) {
result[key] = deepClone(o[key])
return result
}, Object.create(Object.getPrototypeOf(o))) }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment