We have learned how to use optional and default parameters to increase the number of ways that we can invoke a function. Let's return one more time to the previous example:
function add(foo: number, bar: number, foobar: number = 0): number { return foo + bar + foobar; }
We have learned how to invoke the add function with two or three parameters, but what if we wanted to allow other developers to pass four or five parameters to our function? We would have to add two extra default or optional parameters. And what if we wanted to allow them to pass as many parameters as they need? The solution to this possible scenario is the use of REST parameters. The REST parameter syntax allows us to represent an indefinite ...