Rest Parameters of ES6 with example

An argumnet in javascript with three dots in prefix to the variable which will be the function's last parameter, and all the argumnet passed to the function will be present in the array
    Here is an example  of   rest parameters of ES6

    function checkRestParameters(...val) {


    Output in the console 

            0: 1
            1: 2
            2: 3
            3: 4
            4: 5
            5: 5
            6: 6
            length: 7
    Here in the above function  "checkRestParameters"  we are seeing only one arugment with three dots this is called as rest parameters . When the fucntion is invoked by passing arguments to it it will  be present in the array , you can pass any number of argument , the rest parameters should be last argument in the function .   Rest parameters of ES6 with example