Javascript - Functions - Invocation


// JavaScript - Functions - Invocation Patterns:

In addition to the declared parameters, every function receives two additional
parameters: this and arguments.  The this parameter is very important in 
object oriented programming, and its value is determined by the invocation 
pattern.  There are four invocation patterns in JavaScript:

1. the method invocation pattern: objectInstance.methodName(...)
2. the function invocation pattern: functionName(...)
3. the constructor invocation pattern: new FunctionName(...)
4. the apply invocation pattern: functionName.apply(contextObject, optionalArray)

The invocation operator is a pair of parentheses.  The parentheses can contain
zero or more expressions, separated by commas.  Each expression produce one 
argument value.  Each of the argument values will be assigned to the function's 
parameter names.  There is no runtime error when the number of arguments and 
the number of parameters do not match.  If there are too many argument values, 
the extra argument values will be ignored (but are still accessible via the 
arguments array).  If there are too few argument values, the undefined value 
will be substituted for the missing values.  There are no type-checking on the 
argument values: any type of value can be passed to any parameter.
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License