Hidden Features of JAVA Script?

0 votes
44 views
asked Nov 8, 2013 in java script by kalpana (3,995 points)
Hi All

    Hidden Features of JAVA Script?

1 Answer

0 votes
answered Nov 8, 2013 by sahana (2,250 points)

You don't need to define any parameters for a function. You can just use the function's arguments array-like object.

function sum() {
    var retval = 0;
    for (var i = 0, len = arguments.length; i < len; ++i) {
        retval += arguments[i];
    }
    return retval;
}

sum(1, 2, 3)
...