Test name | Executions per second |
---|---|
JSON.parse(JSON.stringify( | 3.0 Ops/sec |
structuredClone( | 0.7 Ops/sec |
const myObj1 = {};
const numLoops = 1000000;
for (let i = 0; i < numLoops; i += 1){
const myObj2 = JSON.parse(JSON.stringify(myObj1));
}
const myObj1 = {};
const numLoops = 1000000;
for (let i = 0; i < numLoops; i += 1){
const myObj2 = structuredClone(myObj1);
}