Run details:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.0.0 Safari/537.36
Chrome 114
Windows
Desktop
one year ago
Test name Executions per second
JSON stringify and parse 389609.0 Ops/sec
structuredClone 184669.1 Ops/sec
Destructuring and Restructuring 7866829.5 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 };