Created
May 28, 2020 21:49
-
-
Save jniac/27b0f3374c6ec270f27b68ce573cc0a7 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 deepClone(target) { | |
| if (!target || typeof target !== 'object') | |
| return target | |
| const clone = Array.isArray(target) ? [] : {} | |
| for (const [key, value] of Object.entries(target)) { | |
| clone[key] = deepClone(value) | |
| } | |
| return clone | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment