Created
October 31, 2019 15:53
-
-
Save kevin-bruton/e71f1dcc087d64d387e2228d3b8e8cc5 to your computer and use it in GitHub Desktop.
This file contains 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
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