What is difference between arr=[...arguments] and [arr0,arr1]=arguments

Tell us what’s happening:
Describe your issue in detail here.
i don’t know where is my issue?

and this’s the solution to this challenge.
Your code so far

function addTogether() {
  const arr=[...arguments];
      return undefined;
    return (arr[1])=>addTogether(arr[0],arr[1]);
    return undefined;
  return arr[0]+arr[1];


Your browser information:

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

Challenge: Arguments Optional

Link to the challenge:

What is difference between…


That is making a shallow copy of arguments and storing it in arr.


That is destructuring the array arguments. It will make a copy of the first element (the reference if it is a reference type) in that array and store it in arr0 and store the second in arr1.

What does this mean?

return (arr[1])=>addTogether(arr[0],arr[1]);

function addTogether() {
const [first, second] = arguments;
if (typeof(first) !== “number”)
return undefined;
if (second === undefined)
return (second) => addTogether(first, second);
if (typeof(second) !== “number”)
return undefined;
return first + second;
and this is the solution to the problem.
I imitated that.

i see.that’s very helpful,thank you.

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.