Use of Rest In javascript

We have new feature called as Rest operator in ECMAScript 2015 . Please find below use case of this interesting operator.

<script>
const getMe = function(a,b,...all)
{
    console.log("All",all);
}
getMe(1,2,3,4,5,6,7,8,9,10);
</script>

If you will run above code then it will show an array of all other parameters except 1 and 2.

See below screenshot which shows the array result.

 

I hope this helps you to understand this feature.

Thank you.

Blog Catagory : JAVASCRIPT