Files
developer-roadmap/src/data/question-groups/javascript/content/rest-parameter.md
T

672 B

The rest parameter allows you to represent many arguments in an array. It's useful when you need a function to accept extra arguments beyond what you've listed.

JavaScript interview questions: rest parameter

The "rest parameter" syntax consists of three dots (...) followed by the name of a parameter. Also, if you're using a rest parameter with other values, make sure it's the last one on the list.

function functionName(...restParameter) {
    // Body of the function
}

// Example 2

function functionName(value1, value2, ...restParameter) {
    // Body of the function
}