6.1 Function Declarations

Function declarations are extended to permit the function body to be omitted in overload declarations.

  FunctionDeclaration: ( Modified )   functionBindingIdentifieroptCallSignature{FunctionBody}   functionBindingIdentifieroptCallSignature;

A FunctionDeclaration introduces a named value of a function type in the containing declaration space. The BindingIdentifier is optional only when the function declaration occurs in an export default declaration (section 11.3.4.2).

Function declarations that specify a body are called function implementations and function declarations without a body are called function overloads. It is possible to specify multiple overloads for the same function (i.e. for the same name in the same declaration space), but a function can have at most one implementation. All declarations for the same function must specify the same set of modifiers (i.e. the same combination of declare, export, and default).

When a function has overload declarations, the overloads determine the call signatures of the type given to the function object and the function implementation signature (if any) must be assignable to that type. Otherwise, the function implementation itself determines the call signature.

When a function has both overloads and an implementation, the overloads must precede the implementation and all of the declarations must be consecutive with no intervening grammatical elements.