// Created on savesnippets.com · https://savesnippets.com/RgvYrZ9jINtKLE function deepClone(value) { if (typeof structuredClone === 'function') { return structuredClone(value); } return JSON.parse(JSON.stringify(value)); } // Usage const original = { a: 1, b: { c: [2, 3] } }; const copy = deepClone(original); copy.b.c.push(4); console.log(original.b.c); // [2, 3] — untouched