How to deeply clone an object in JavaScript? The simplest way is via JSON eg.
JSON.parse(JSON.stringify(obj))
See below for two alternatives which use browser APIs in unexpected ways.
The first one, the asynchronous PostMessage version runs 7 times faster than the JSON approach. These methods also have the advantage of working with circular references and non-serializable types like Dates, Sets, Maps and ArrayBuffers etc.
Something a little less wierd really needs to get built into JavaScript.
https://twitter.com/dassurma/status/955484341358022657


