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.
function.arguments
refere-se a um objecto com aspecto de array que corresponde aos argumentos da função. Ao invés disso, use a variável arguments
. Esta propriedade é proibida no modo strict devido ao tail call optimization.Descrição
A síntaxe function.arguments
está obsoleta. A forma recomendade de aceder ao objecto arguments
disponível nas função é usar simplesment a variável arguments
.
No caso de recursão isto é, se uma funão f
aparece várias vezes na stack, o valor de f.arguments
representa os argumentos correspondentes à mais recente chamada da função.
O valor da propriedade arguments
é tipicamente null se não há nenuma invocação da função a acontecer, ou seja, a função foi chamada mas ainda não retornou.
Exemplos
function f(n) { g(n - 1); }
function g(n) {
console.log('antes: ' + g.arguments[0]);
if (n > 0) { f(n); }
console.log('depois: ' + g.arguments[0]);
}
f(2);
console.log('retornado: ' + g.arguments);
// Output
// antes: 1
// antes: 0
// depois: 0
// depois: 1
// retornado: null
Especificações
Specification | Status | Comment |
---|---|---|
ECMAScript 1st Edition (ECMA-262) | Standard |
Definição inicial. Implementado em JavaScript 1.0. Tornado obsoleto a favor de |
ECMAScript 5.1 (ECMA-262) The definition of 'arguments object' in that specification. |
Standard | Objecto arguments |
ECMAScript 2015 (6th Edition, ECMA-262) The definition of 'arguments object' in that specification. |
Standard | Objecto arguments |
ECMAScript (ECMA-262) The definition of 'arguments object' in that specification. |
Living Standard | Objecto arguments |
Compatibilidade navegadores
BCD tables only load in the browser