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 Latest Draft (ECMA-262) The definition of 'arguments object' in that specification. |
Draft | arguments object |
Compatibilita' Browser
| Desktop | Mobile | Server | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
arguments | Chrome Full support 1 | Edge Full support 12 | Firefox Full support 1 | IE Full support 4 | Opera Full support Yes | Safari Full support Yes | WebView Android Full support 1 | Chrome Android Full support 18 | Firefox Android Full support 4 | Opera Android Full support Yes | Safari iOS Full support Yes | Samsung Internet Android Full support 1.0 | nodejs Full support Yes |
Legend
- Full support
- Full support
- Deprecated. Not for use in new websites.
- Deprecated. Not for use in new websites.