Rest Parameter
noun
say it: “REST puh-RAM-uh-ter” /rɛst pəˈræmɪtər/ or “DOT DOT DOT” /dɒt dɒt dɒt/
A last function parameter written with three dots, such as ...scores, that gathers all the remaining arguments into one array.
What is Rest Parameter in JavaScript?
Rest Parameter — A final function parameter beginning with ... that collects remaining arguments into an array.
function total(...prices) {
return prices.reduce((sum, price) => sum + price, 0);
}
In a sentence
- “Thanks to the rest parameter, addToCart('mug', 'beans', 'filter') put all three items in one array.”
Level: Apprentice · More JavaScript terms at this level
Updated