deep copy javascript

JavaScript
JSON.parse(JSON.stringify(object))let clone = Object.assign({}, objToClone);var cloned = JSON.parse(JSON.stringify(objectToClone));function copy(arr1, arr2) {
	for (var i =0; i< arr1.length; i++) {
    	arr2[i] = arr1[i];
    }
}
copy(arr1, arr2)const deepCopyFunction = (inObject) => {
  let outObject, value, key

  if (typeof inObject !== "object" || inObject === null) {
    return inObject // Return the value if inObject is not an object
  }

  // Create an array or object to hold the values
  outObject = Array.isArray(inObject) ? [] : {}

  for (key in inObject) {
    value = inObject[key]

    // Recursively (deep) copy for nested objects, including arrays
    outObject[key] = deepCopyFunction(value)
  }

  return outObject
}JSON.parse(JSON.stringify(o))
Source

Also in JavaScript: