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)
| 35 | |
| 36 | |
| 37 | function 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 | |
| 57 | let arr = [[1], [2, [3]]]; |