Run details:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.0.0 Safari/537.36
Chrome 114
Mac OS X 10.15.7
Desktop
one year ago
Test name Executions per second
JSON stringify and parse 584641.9 Ops/sec
structuredClone 312535.2 Ops/sec
Destructuring and Restructuring 14875885.0 Ops/sec
Script Preparation code:
AخA
 
var obj = {a: "hello", c: "test", po: 33, arr: [1, 2, 3, 4], anotherObj: {a: 33, str: "whazzup"}};
Tests:
  • JSON stringify and parse

     
    const obj1 = JSON.parse(JSON.stringify(obj));
  • structuredClone

     
    const obj2 = structuredClone(obj);
  • Destructuring and Restructuring

     
    const obj3 = { ...obj };