Rest parameters (…args)
Hello guys how are you doing today i hope you all good !
Simple example of Rest parameter………….
Get Ramesh Raveendran’s stories in your inbox
Join Medium for free to get updates from this writer.
The rest parameter in JavaScript is used in functions to collect extra arguments into an array. It is written using three dots (...). For example, in the function function greet(...names), if we call greet("John", "Jane", "Jim"), all the names will be collected into an array called names → ["John", "Jane", "Jim"]. This is useful when we don't know how many arguments will be passed.
Key Points:
- Only one rest parameter is allowed.
- It must be the last parameter.
- It always returns an array.







