What are Rest parameters in JavaScript ?

js restParameter
Feature Driven Development

MOTOSHARE 🚗🏍️
Turning Idle Vehicles into Shared Rides & Earnings

From Idle to Income. From Parked to Purpose.
Earn by Sharing, Ride by Renting.
Where Owners Earn, Riders Move.
Owners Earn. Riders Move. Motoshare Connects.

With Motoshare, every parked vehicle finds a purpose. Owners earn. Renters ride.
🚀 Everyone wins.

Start Your Journey with Motoshare

The rest parameter syntax allows a function to accept an indefinite number of arguments as an array, providing a way to represent variadic functions in JavaScript.

Now, What is variadic function ?

In mathematics and in computer programming, a variadic function is a function of indefinite arity, i.e., one which accepts a variable number of arguments. Support for variadic functions differs widely among programming languages.

What is Rest parameter

A function definition’s last parameter can be prefixed with “...” , which will cause all remaining (user supplied) parameters to be placed within a “standard” JavaScript array.. Only the last parameter in a function definition can be a rest parameter.

JavaScript Demo: Functions Rest Parameters