13 ms·
> If you don’t expect cyclic objects and don’t need to preserve built-in types, you get the fastest clone across all browsers by using JSON.parse(JSON.stringify
by codeisawesome 9y ago
> If you don’t expect cyclic objects and don’t need to preserve built-in types, you get the fastest clone across all browsers by using JSON.parse(JSON.stringify()), which I found quite surprising.
I wonder if that’s because browser devs know by now that this is a widely used technique and hence optimise for it.
- Havelock 9y agoI suspect it is because JSON.parse and JSON.stringify are more commonly used methods and therefore see more optimization than methods use less.