Rest Parameter to Reassign Array Elements

Tell us what’s happening:
Hi… i am confused with this exercise. The code is ok. But i dont understand why if the js understand that with this:

const [a,b, …arr]= list;

the result is: list = [1,2,3,4,5,6,7,8,9,10]

what i mean is, i first use this code:

const [a,b, …arr]=[1,2,3,4,5,6,7,8,9,10] and coding this i would understand the answer of the exercice, but i dont understand how can the js that list = the array…

Your code so far

const source = [1,2,3,4,5,6,7,8,9,10];
function removeFirstTwo(list) {
"use strict";
// Only change code below this line
const [a,b, ...arr]= list; // Change this line
// Only change code above this line
return arr;
const arr = removeFirstTwo(source);

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.121 Safari/537.36.

Challenge: Use Destructuring Assignment with the Rest Parameter to Reassign Array Elements

Link to the challenge:

source is [1,2,3,4,5,6,7,8,9,10]. This same array gets passed by reference with the following call:


Inside the function, list is the same array that was passed into the function, so you are just destructuring [1,2,3,4,5,6,7,8,9,10].