how to deep copy an object in javascript

JavaScript
JSON.parse(JSON.stringify(object))let clone = Object.assign({}, objToClone);JSON.parse(JSON.stringify(o))const obj1 = { a: 1, b: 2, c: 3 };
// this converts the object to string so there will be no reference from 
// this first object
const s = JSON.stringify(obj1);

const obj2 = JSON.parse(s);
Source

Also in JavaScript: