typeof operator returns the string
“function” when applied to a function, but functions are really a
they can have properties and methods, just like any other object.
There is even a
constructor to create new function objects. The subsections that
follow document function properties and methods and the
Function() constructor. You can also read
about these in the reference section.
Within the body of a function,
arguments.length specifies the number of
arguments that were passed to the function. The
length property of a function itself,
however, has a different meaning. This read-only property returns
the arity of the function—the number of
parameters it declares in its parameter list, which is usually the
number of arguments that the function expects.
The following code defines a function named
check() that is passed the
arguments array from another function. It
number of arguments actually passed) to
arguments.callee.length (the number
expected) to determine whether the function was passed the right
number of arguments. If not, it throws an exception. The
check() function is followed by a test
f() that demonstrates
check() can be used:
// This function uses arguments.callee, so it won't work in strict mode.