Not so new to FCC, but brand new to the forum (although been lurking for some time). I’m working through the Javascript part of FCC’s lessons (on the functional programming part) and something I’m confused with is this:
let someArr = [1, 2, 3, 4, 5];
let copyArr = [...someArr];
let copyArr2 = someArr.slice();
Are both copyArr and copyArr2 exact copies of someArr or is one of them merely a reference? I understand the use-case for slice(), but what is it that [...] does?
This has answered my question, thank you!
To anyone else also wondering, the .slice() will only work on arrays, where as spread ([…]) will work on any iterable.