Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.
Functions are defined with the function keyword, which can be used in a
function definition expression (Function Definition) or in a
function declaration statement (function). In
either form, function definitions begin with the keyword function followed by these components:
An identifier that names the function. The name is a required part of function declaration statements: it is used as the name of a variable, and the newly defined function object is assigned to the variable. For function definition expressions, the name is optional: if present, the name refers to the function object only within the body of the function itself.
A pair of parentheses around a comma-separated list of zero or more identifiers. These identifiers are the parameter names for the function, and they behave like local variables within the body of the function.