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.
Loading...
Related Quiz
- How does cache eviction strategy LRU (Least Recently Used) work?
- What type of files are generally served as static files in Express.js?
- How does JavaScript’s prototypal inheritance differ from classical inheritance models?
- What is the primary purpose of running the npm init command in a Node.js project?
- What is the significance of the 'newListener' event in the Events module of Node.js?