Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.
A function is a block of JavaScript code
that is defined once but may be executed, or invoked,
any number of times. You may already be familiar with the concept of a
function under a name such as subroutine or procedure. JavaScript functions are
parameterized: a function definition may
include a list of identifiers, known as parameters,
that work as local variables for the body of the function. Function
invocations provide values, or arguments, for the function’s parameters.
Functions often use their argument values to compute a return value that becomes the value of
the function-invocation expression. In addition to the arguments, each
invocation has another value—the invocation context—that is the value of
the this keyword.