[ Web Proxy ]
URL:
Viewing: https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Function/arguments [Back]  [Original]

Function.prototype.arguments - JavaScript | MDN

MDN Web Docs

View in English Always switch to English

Function.prototype.arguments

Deprecated

Avoid using this feature in new projects. JavaScript strict mode prohibits accessing the caller and arguments properties of a Function object. This feature may be a candidate for removal from web standards or browsers.

:

Function arguments arguments arguments

Function arguments arguments TypeError

arguments

f f.arguments

arguments null

ECMAScript Function.prototype arguments get set TypeErrorarguments Chrome Firefox Safari Function.prototype.arguments this

js
(function f() {
  if (Object.hasOwn(f, "arguments")) {
    console.log(
      "arguments ",
      Object.getOwnPropertyDescriptor(f, "arguments"),
    );
  } else {
    console.log(
      "f  arguments  f.[[Prototype]].arguments",
    );
    console.log(
      Object.getOwnPropertyDescriptor(
        Object.getPrototypeOf(f),
        "arguments",
      ).get.call(f),
    );
  }
})();

//  Chrome 
// arguments  {value: Arguments(0), writable: false, enumerable: false, configurable: false}

//  Firefox 
// f  arguments  f.[[Prototype]].arguments
// Arguments {  }

arguments

js
function f(n) {
  g(n - 1);
}

function g(n) {
  console.log(`${g.arguments[0]}`);
  if (n > 0) {
    f(n);
  }
  console.log(`${g.arguments[0]}`);
}

f(2);

console.log(`${g.arguments}`);

// 
// 1
// 0
// 0
// 1
// null


Web Proxy Viewer  |  New URL  |  Original Page