Sometimes I see JavaScript that is written with an argument provided that already has a set value or is an object with methods. Take this jQuery example for instance:
Yes, you are passing functions as arguments. The functions that you pass will of course have their own arguments.
And, these arguments can be anything including objects which may have their own methods, etc.
http.createServer
will accept a function and it will know how may arguments that function has. One way to to do this is to check the arguments
property of the passed in function. Or the api developer may have used the actual elements.
The writer of this function will know what is expected as arguments and will document it in the api documentation
.