JSON.stringify 与 structuredClone深拷贝的性能测试
更新于 阅读 19 次
structuredClone与JSON.stringify都能进行深拷贝,但是他们的性能究竟有什么差异呢,下面是本人的测试结果,
测试地址:https://www.measurethat.net/Benchmarks/Show/18541/0/jsonstringify-vs-structuredclone
structuredClone是 ECMAScript 2020 中引入的一个相对较新的函数,此方法比 JSON.stringify 更安全、更快,因为它避免了解析并直接创建深层副本:它可以更健壮地处理循环引用和其他边缘情况。它通常比 JSON.stringify 更快。
标签:JSON.stringifystructuredClone
