Rest Parameters

suggest change
function argumentLength(...args) {
    return args.length;
}

argumentLength(5) // returns 1
argumentLength(5, 3) //returns 2
argumentLength(5, 3, 6) //returns 3

Prefix the last parameter with ... and every argument from that position on is collected into an array. Here the function returns how many arguments were passed.

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents