arguments.length
La propietat arguments.length
conté el número d'arguments passats a la funció.
Sintaxi
arguments.length
Descripció
La propietat arguments.length proporciona el número d'arguments passats a la funció. Aquest pot ser major o menor que el nombre total de paràmetres definits. (Vegeu Function.length
).
Exemples
Utilitzar arguments.length
En aquest exemple definim una funció que pot afegir dos o més nombres.
function adder(base /*, n2, ... */) {
base = Number(base);
for (var i = 1; i < arguments.length; i++) {
base += Number(arguments[i]);
}
return base;
}
Especificacions
Especificació | Estat | Comentaris |
---|---|---|
ECMAScript 1st Edition (ECMA-262) | Standard | Definició inicial. Implementat en JavaScript 1.1 |
ECMAScript 5.1 (ECMA-262) The definition of 'Arguments Object' in that specification. |
Standard | |
ECMAScript 2015 (6th Edition, ECMA-262) The definition of 'Arguments Exotic Objects' in that specification. |
Standard |
Compatibilitat amb navegadors
We're converting our compatibility data into a machine-readable JSON format.
This compatibility table still uses the old format,
because we haven't yet converted the data it contains.
Find out how you can help!
Característica | Chrome | Firefox (Gecko) | Internet Explorer | Opera | Safari |
---|---|---|---|---|---|
Suport bàsic | (Yes) | (Yes) | (Yes) | (Yes) | (Yes) |
Característica | Android | Chrome per Android | Firefox Mobile (Gecko) | IE Mobile | Opera Mobile | Safari Mobile |
---|---|---|---|---|---|---|
Suport bàsic | (Yes) | (Yes) | (Yes) | (Yes) | (Yes) | (Yes) |