Last active
April 17, 2020 08:27
-
-
Save koyanloshe/19e6c64d0ce0749ed5987b514475adbb to your computer and use it in GitHub Desktop.
Cloning objects without effects #Javascript
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
// Object.assign has an issue with nested Objects. This prevents that leakage | |
const cloneObj = (existingObj) => { | |
return JSON.parse(JSON.stringify(existingObj)) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment