JavaScript Rest Operator

JavaScript Rest Operator


JavaScript Rest Operator
JavaScript Rest Operator represented by (….) as same as spread operator. The main difference between rest and spread is that the rest operator puts the rest of some specific user-supplied values into a JavaScript array. But the spread syntax expands iterables into individual elements using rest parameters is describing below:
  • Rest parameters allows represents an indefinite number of arguments as an array.
  • Rest parameters of the function prefixed with(…).
  • The Rest parameters index starts with zero index.
  • Rest parameters must be last parameter of function arguments.
Syntax
function function_Name(…restParams){
             // function body
}
function_Name()       // caling function
Example
Output
Rest Operators
10
15