nas5w/javascript-tips-and-tidbits

A slight alteration to Rest Syntax section for better understanding

Abdul-Sen opened this issue · 0 comments

I read through the Rest Syntax section and I felt it was improvement could be made by letting readers know that you can use declared params and rest syntax together. We can either state that ...args has to be the last function argument in text or update the example to the following (or do both 🙂):

function myFunc(param1, ...args) {
    console.log(param1 + args[0] + args[1]);
}

myFunc("The Result is: " , 1, 2, 3, 4);
// The Result is: 3

I'd be happy to make the pull request.