Skip to content

Instantly share code, notes, and snippets.

@kevin-bruton
Created October 31, 2019 15:53
Show Gist options
  • Save kevin-bruton/e71f1dcc087d64d387e2228d3b8e8cc5 to your computer and use it in GitHub Desktop.
Save kevin-bruton/e71f1dcc087d64d387e2228d3b8e8cc5 to your computer and use it in GitHub Desktop.
const deepCopy = aObject => {
if (!aObject) { return aObject; }
const bObject = Array.isArray(aObject) ? [] : {};
// tslint:disable-next-line: forin
for (const k in aObject) {
bObject[k] = aObject[k] === null ? null : (typeof aObject[k] === 'object') ? deepCopy(aObject[k]) : aObject[k];
}
return bObject;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment