Skip to content

Instantly share code, notes, and snippets.

@nonlogos
Created November 16, 2017 15:04
Show Gist options
  • Select an option

  • Save nonlogos/ac11b4b5508fa8a46a37b97abbde1411 to your computer and use it in GitHub Desktop.

Select an option

Save nonlogos/ac11b4b5508fa8a46a37b97abbde1411 to your computer and use it in GitHub Desktop.
deep copy for objects and arrays
function copy(object) {
var output, value, key;
output = Array.isArray(object) ? [] : {};
for (key in object) {
value = object[key];
output[key] = (typeof value === 'object') ? copy(value) : value;
}
return output;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment