next up previous contents
Next: Array Object Up: Properties Previous: Properties   Contents


arguments

Description

A local object variable containing each argument passed to the currently executing function. It is automatically created by Ffish script for the currently executing function. The variable can be accessed just like an array. The only difference is that it has a callee property, which refers to the function being called.


Syntax

arguments[]


Examples

//Use arguments property to
//handle variant number of arguments
function sum()
{
    s = 0;
    for (i = 0; i < arguments.length; i++)
    s += arguments[i];
    return s;
}

sum(1,2,3,4,5,6,7);
//The callee property of arguments
//often used in the anonymous functions.
function sum()
{
    this.cal = function ()
    {
        o = arguments;
        if (o[0] <= 0) return o[0];
        return o[0] + o.callee(o[0] - 1);
    }
}

r = new sum();
trace(r.cal(100));
//output: 5050




Copyright ©2000-2010 Shanghai TopCMM Software Technologies. All Rights Reserved.