I have run across code that invokes a function as fn(a,b,c) but the definition of fn is fn(a,b) and then inside the author invokes arguments[2] which would imply a third undeclared argument. Is this legit? (I am new to the site and tried to search for a related question before posting, but was unable to find one. If there is a custom for doing so, I would love to be educated.) Thanks.
Share
It’s allowed. It’s usually better to specify good argument names and then check if they are null or not, for readability and sanity. People reading your code won’t expect or understand that technique.
There are cases where it acceptable… for example:
However, even in this case it would be better to add placeholder variable names for the sake of readers: