ECMA Script functions are specified in terms of FunctionDeclaration and FunctionExpression :
These expressions for FunctionDeclaration and FunctionExpression are processed for function declarations and evaluated in two steps as follows : First, the script engine creates a new Function object with parameters specified by FormalParameterList , and body specified by FunctionBody ; the scope chain of the running execution context is used for the current execution scope. Next, for FunctionDeclaration , the script engine creates a property of the current variable object with name Identifier and value resulting from the first step above. For FunctionExpression the script engine creates a similar property but, in case that Identifier is not present (i.e., anonymous function), assigns this property an internal name and renders it inaccessible to the script program. The Identifier in a FunctionExpression can be referenced from inside the FunctionExpression's FunctionBody to allow the function to call itself recursively. However, unlike in a FunctionDeclaration , the Identifier in a FunctionExpression cannot be referenced from and does not affect the scope enclosing the FunctionExpression . Two functions are considered to be the equal in the following cases:
Functions obtained from distinct calls to the Function constructor or calls to eval() are never considered the equal, even if those two calls to eval() were passed the same argument. |