Which JavaScript expression uses the rest operator?

  • function myFunction(a, b, ...rest)
  • const [x, y, ...rest] = arr;
  • const {x, y, ...rest} = obj;
  • const rest = [a, b, ...c];
The rest operator (...) is used in function parameters to collect all remaining arguments into an array. In the example function myFunction(a, b, ...rest), the ...rest collects any additional arguments passed to the function into an array named rest.
Add your answer
Loading...

Leave a comment

Your email address will not be published. Required fields are marked *