Deprecated
This feature is no longer recommended. Though some browsers might still support it, it may have already been removed from the relevant web standards, may be in the process of being dropped, or may only be kept for compatibility purposes. Avoid using it, and update existing code if possible; see the compatibility table at the bottom of this page to guide your decision. Be aware that this feature may cease to work at any time.
La propietat function.arguments
es refereix a un objecte que s'assembla a una array corresponent als arguments passats a una funci贸. Utilitzeu la variable simple arguments
.
Descripci贸
La sintaxis function.arguments
茅s obsoleta. El cam铆 recomanat per accedir a l'objecte arguments
disponible en les funcions requereix simplement referir-se a la variablearguments
.
En cas de recursivitat, 茅s a dir, si la funci贸 f
apareix v脿ries vegades en la pila de crides, el valor det f.arguments
representa els arguments corresponents a la invocaci贸 m茅s recent de la funci贸.
El valor del la propietat arguments normalment 茅s null si no hi ha una invocaci贸 excel路lent de la funci贸 (aix貌 vol dir, que s'ha cridat la funci贸 per貌 la seva execuci贸 encara no s'ha acabat).
Exemples
function f(n) { g(n - 1); }
function g(n) {
console.log('before: ' + g.arguments[0]);
if (n > 0) { f(n); }
console.log('after: ' + g.arguments[0]);
}
f(2);
console.log('returned: ' + g.arguments);
// Resultat
// abans: 1
// abans: 0
// despr茅s: 0
// despr茅s: 1
// retorn: null
Especificacions
Especificaci贸 | Estat | Comentaris |
---|---|---|
ECMAScript 1st Edition (ECMA-262) | Standard | Definici贸 inicial. Implementat en JavaScript 1.0. Obsolet a favor de arguments en ES3. |
ECMAScript 5.1 (ECMA-262) The definition of 'arguments object' in that specification. |
Standard | arguments object |
ECMAScript 2015 (6th Edition, ECMA-262) The definition of 'arguments object' in that specification. |
Standard | arguments object |
Compatibilitat amb navegadors
Caracter铆stica | Chrome | Firefox (Gecko) | Internet Explorer | Opera | Safari |
---|---|---|---|---|---|
Suport b脿sic | (Yes) | (Yes) | (Yes) | (Yes) | (Yes) |
Caracter铆stca | Android | Chrome per Android | Firefox Mobile (Gecko) | IE Mobile | Opera Mobile | Safari Mobile |
---|---|---|---|---|---|---|
Suport b脿sic | (Yes) | (Yes) | (Yes) | (Yes) | (Yes) | (Yes) |