Rest Parameters Quiz
Question
What does `...nums` represent in `function sum(...nums) { return nums.reduce((a, b) => a + b, 0); }`?
Hint
In function parameters, ... is the rest parameter syntax.
Explanation
In a function parameter list, ...nums is a rest parameter — it collects all remaining arguments into an array named nums. So sum(1, 2, 3) makes nums = [1, 2, 3]. The same ... syntax is a spread operator when used in calls or array literals, but in parameter declarations it is always a rest parameter.
Related Resources
Related Lessons
- JavaScript Functions
Learn about rest parameters.
Look up unfamiliar terms
A beginner-friendly glossary explains jargon in plain English — variables, functions, DOM, Promise, and more.
Decode error messages
Plain-English explanations of common errors — what they mean, why they happen, and how to fix them.
Build real projects
Apply what you learned by building guided projects with starter code and solutions.