ECMA-262 Core: JavaScript Call Statements



Navigation Aids -- This Page        Navigation Aids -- This Topic        Navigation Aids -- This Site








Introduction And Review

The call statement can be used to invoke a JavaScript function. We have categorized the function call statement as belonging to the expression statement group of statements. Reviewing the function call statement definition, we see that there are three parts to the syntax of the function call statement. This page will address each part. The syntax of the function call statement is given here followed with links to the details:

function_name(optional parameters)
  1. function name
  2. parentheses operator
  3. optional parameters


Statement Execution Flow

The program execution flow for the interaction between the function call statements (caller) and the target named function (callee) will prescribe to the following sequential events:



function_name

The function call statement will invoke a function that has been previously declared (and named). The exception to the precedence rule; if the function declaration and the function call statement are within the same <script> tag set, the call can be issued before the declaration. The function_name is an identifier and JavaScript has rules for its identifiers. The function_name may originate from one of three function declaration methods:

  1. JavaScript Function Statement Declaration
  2. JavaScript Function Literals
  3. The Function Object (Class)

With regards to the Function class, the call statement invokes an instance of the class, that is, a named object of the class.



Function Name Scope Considerations

We cover the topics of variable scope and the scope chain at our page entitled Variable Scope. Briefly, functions declared at the top-level code, will have a function name with global scope. Functions declared within the page body will create a call object when called. The names of these functions behave like locally scoped variables. Functions declared within another function (nesting), also create there own call object.



Review of the Parentheses Operator

The parentheses that enclose the optional parameter list is actually a JavaScript operator. The parentheses operator takes at least two operands. The left hand side contains the function operand. The other operand is the argument operand. The argument operand represents the augment values or expressions enclosed by the parentheses operator. Each argument value is considered an operand. Therefore, technically the parentheses operator may have more than two operands given it has more than one argument value.



The Optional Arguments (Actual Parameters)

Semantically, we are using the term parameter and the term argument interchangeably. When referring to the argument operand and the argument list that it represents, the term argument fits nicely. However, elsewhere, when discussing objects, we use the term actual parameter to describe the arguments that the caller passes to the callee. The actual parameters that are passed to the function should match the named formal parameter in the function header.



Top            

Rx4AJAX        About Us | Topic Index | Contact Us | Privacy Policy | 2008 This Site Built By PPThompson