Rest Parameters
suggest changefunction 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.
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents