6.6 Code Generation

A function declaration generates JavaScript code that is equivalent to:

  1. function <FunctionName>(<FunctionParameters>) {
  2. <DefaultValueAssignments>
  3. <FunctionStatements>
  4. }

FunctionName is the name of the function (or nothing in the case of a function expression).

FunctionParameters is a comma separated list of the function’s parameter names.

DefaultValueAssignments is a sequence of default property value assignments, one for each parameter with a default value, in the order they are declared, of the form

  1. if (<Parameter> === void 0) { <Parameter> = <Default>; }

where Parameter is the parameter name and Default is the default value expression.

FunctionStatements is the code generated for the statements specified in the function body.