Created
January 27, 2018 20:22
-
-
Save AutoSponge/6ce692db4f5f2e5ca974e08900d95a5e to your computer and use it in GitHub Desktop.
deep copy of obj in browser
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 structuredClone(obj) { | |
const oldState = history.state | |
history.replaceState(obj, window.title) | |
const copy = history.state | |
history.replaceState(oldState, window.title) | |
return copy | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
credit @DasSurma