arguments.length Redirect 1


Specifies the number of arguments passed to the function.

Property of arguments
Implemented in JavaScript 1.1
ECMAScript Edition ECMA-262


arguments.length provides the number of arguments actually passed to a function. This can be more or less than the defined parameter count (See Function.length).


Example: Using arguments.length

In this example we are define a function that can add two or more numbers together.

function adder(base, /*, n2, ... */) {
  base = Number(base);
  for (var i = 0; i < arguments.length; i++) {
    base += Number(arguments[i]);
  return base;

See also

Document Tags and Contributors

 Last updated by: Sheppy,