MCPcopy Create free account
hub / github.com/appacademy/Module-1-Resources / deepDup

Function deepDup

w3/d3/deepDup.js:37–54  ·  view source on GitHub ↗

A shallow copy makes a copy of the reference to X (an array), into Y. If we were to say something like this for example: let x = [ [1], [2, 3] ]; let y = x.slice(); In this situation, Y, is a shallow copy of X. Here both X's and Y's VALUES point to the same place in memory. But hold on you might sa

(arr)

Source from the content-addressed store, hash-verified

35
36
37function deepDup(arr) {
38
39 let dupArr = [];
40 debugger;
41 for(let ele of arr) {
42 debugger;
43 if(Array.isArray(ele)) {
44 debugger;
45 let copy = deepDup(ele)
46 dupArr.push(copy);
47 } else {
48 debugger;
49 dupArr.push(ele);
50 }
51 };
52 debugger;
53 return dupArr;
54}
55
56
57let arr = [[1], [2, [3]]];

Callers 1

deepDup.jsFile · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected