...rest / ...spread
Gathers a variable number of arguments / expands an array.
Syntax
function name(...args) { }Description
In function definition, ...args gathers remaining arguments into an array. In a call, ...array spreads the array into individual elements (spread).
Example
Loading editor…
Expected output
10
When to use?
Indefinite number of arguments, merging arrays.