Created
October 7, 2018 21:02
-
-
Save MaximStone/59b4215ed37bb2ba53d88f00c0d2410a to your computer and use it in GitHub Desktop.
Deep copy function
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
function deepCopy(obj) { | |
let result = {}; | |
for (var key in obj) { | |
if (typeof obj[key] === 'object') { | |
result[key] = deepCopy(obj[key]); | |
} else { | |
result[key] = obj[key]; | |
} | |
} | |
return result; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment