Deprecato
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 proprieta' function.arguments
fa riferimento ad un oggetto simile ad un array corrispondente ai parametri passati ad una funzione. Usa questa semplice variabile arguments
invece. Questa proprieta' non e' disponibile in strict mode.
Descrizione
La sintassi function.arguments
e' deprecata. Il metodo consigliato per accedere all'oggetto arguments
, disponibile all'interno delle funzioni e' semplicemente mediante l'utilizzo di arguments
.
In caso di ricorsione, per esempio, se la funzione f
e' presente diverse volte nello stack, il valore di f.arguments
rappresenta i parametri corrispondenti alla chiamata alla funzione piu' recente.
Il valore della proprieta' arguments e' normalmente null se non c'e' una sua chiamata durante l'esecuzione della funzione (ovvero quando la funzione e' stata chiamata ma non ha ancora ritornato nessun valore).
Esempi
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)
// Output
// before: 1
// before: 0
// after: 0
// after: 1
// returned: null
Specifiche
Specification | Status | Comment |
---|---|---|
ECMAScript 1st Edition (ECMA-262) | Standard | Initial definition. Implemented in JavaScript 1.0. Deprecated in favor of arguments in 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 |
ECMAScript (ECMA-262) The definition of 'arguments object' in that specification. |
Living Standard | arguments object |
Compatibilita' Browser
BCD tables only load in the browser