Spread Operator
Description
The spread operator (...
) in function definitions collects all passed arguments into a single array. This is useful when you want to handle a variable number of arguments in your function.
Syntax
Usage Examples
Important Notes
The spread parameter must be the last (and often only) parameter in the function definition
Inside the function, the spread parameter is treated as a regular array
If no arguments are passed, the spread parameter will be an empty array
You can use any valid array methods on the spread parameter
The spread operator in function definitions is different from the spread operator used to expand arrays
Last updated
Was this helpful?