May 2001
Intermediate to advanced
720 pages
23h 24m
English
arguments.length Property — the number of parameters passed to an argument
Flash 5
arguments.length
Read/write
The length property stores an integer representing
the number of elements in the arguments array,
which equates to the number of parameters passed to the currently
executing function.
We can use the length property of
arguments to determine whether a function was
invoked with the correct number of parameters. The following example
checks whether two arguments have been passed to
someFunction( ). Checking whether the passed
arguments are of the correct type is left as an exercise to the
reader. (Hint: see the typeof operator.)
Here’s the code:
function someFunction (y, z) {
if (arguments.length != 2) {
trace("Function invoked with wrong number of parameters");
return;
}
// Proceed with normal function body...
}Read now
Unlock full access