Last active
April 30, 2019 19:10
-
-
Save splincode/bd6dc43e3e1a04122b8ad4041764f12c 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 deepCopy(obj) { | |
| return JSON.parse(JSON.stringify(obj)); // serialize -> deserialize -> unique clone | |
| } | |
| const original = { | |
| a: undefined, | |
| b: { c: undefined }, | |
| d: () => undefined | |
| }; | |
| // JSON does not have an undefined value. Use null instead of undefined. | |
| const deepCopy = { ...deepCopy(original), e: null }; // { b: { }, e: null } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment