What does this code mean?

Continuing the discussion from freeCodeCamp Challenge Guide: Arguments Optional:

I don’t fully understand the logic of this solution. What does it mean when you put const [something here]. I understand that it sets first and second to the arguments object inputs but why is the [ ] needed? Does it create an array?

Also, I don’t fully understand how the second argument is accessed if it is not included in the original parameters of the function. For example, addTogether(2)([3]). How is the [3] accessed by arguments if it’s not an argument in the original call addTogether(2)?

CamperBot Solution:

That syntax is called destructuring.

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