1const deepCopyFunction = (inObject) => {
2 let outObject, value, key
3
4 if (typeof inObject !== "object" || inObject === null) {
5 return inObject // Return the value if inObject is not an object
6 }
7
8 // Create an array or object to hold the values
9 outObject = Array.isArray(inObject) ? [] : {}
10
11 for (key in inObject) {
12 value = inObject[key]
13
14 // Recursively (deep) copy for nested objects, including arrays
15 outObject[key] = deepCopyFunction(value)
16 }
17
18 return outObject
19}
1function copy(arr1, arr2) {
2 for (var i =0; i< arr1.length; i++) {
3 arr2[i] = arr1[i];
4 }
5}
6copy(arr1, arr2)