JS Basic Tutorial
The Rest (...
) and Spread (...
) operators both use three dots (...
) but serve different purposes based on their context.
...
)The Rest Operator is used to collect remaining arguments into an array.
It is primarily used in function parameters.
Try it yourself
...
)The Spread Operator is used to expand iterable elements (like arrays or objects) into individual elements.
Try it yourself