Function.arguments
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.
A propriedade function.arguments
diz respeito a um objeto tipo array (array-like object) correspondente aos argumentos passados para uma função. Use somente a variável arguments
em vez disso.
Descrição
A sintaxe function.arguments
está obsoleta. A forma recomendada de acessar o objeto arguments
disponível dentro das funções, é simplesmente referenciar a variável arguments
.
No caso de recursão, ou seja, uma função f aparecer várias vezes na pilha de chamadas, o valor de f.arguments
representa os argumentos correspondentes a invocação mais recente da função.
O valor da propriedade arguments é normalmente nulo (null
) se não houver nenhuma invocação pendente da função em andamento (ou seja, a função foi chamada mas ainda não retornou).
Exemplos
js
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
Especificações
Especificação | Status | Comentário |
---|---|---|
ECMAScript 1st Edition (ECMA-262) | Padrão | Definiçao inicial. Implementado em JavaScript 1.0. Obsoleto em favor de arguments em ES3. |
ECMAScript 5.1 (ECMA-262) The definition of 'arguments object' in that specification. |
Padrão | arguments object |
ECMAScript 2015 (6th Edition, ECMA-262) The definition of 'arguments object' in that specification. |
Padrão | arguments object |
ECMAScript (ECMA-262) The definition of 'arguments object' in that specification. |
Padrão em tempo real | arguments object |
Compatibilidade com navegadores
BCD tables only load in the browser