How to use rest operator/ Parameter in javascript

How to use rest operator/ Parameter in javascript

What is the rest parameter?

It is just the opposite of a spread operator. It bounds spreading values into the elements of an array. It gives access to a function to use an indefinite number of arguments as an array. It is denoted by '...' symbol.

syntax

function f(a, b, ...myarg){

//..

}

A function definition can only have one rest parameter and the rest parameter must be the last parameter.

Examples

Let's make a function of various parameters with the rest parameter.