2
let arr = [1,2,3]
let arr2 = [...arr]
let [...arr3] = arr

The arr2 and arr3, both make a shallow copy of arr. What is actually the difference?

bbcts
  • 25
  • 3
  • 6
    No difference, except that `let arr2 = [...arr]` is more understandable (and thus much more common) – CertainPerformance Feb 11 '22 at 02:29
  • As @CertainPerformance said, no difference in your example. However, when doing it as in arr3, you can [destructure the array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Destructuring_assignment) – daniel Feb 11 '22 at 03:14

0 Answers0