[ Web Proxy ]
URL:
Viewing: https://developer.mozilla.org/ja/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

JavaScript strict mode prohibits accessing the caller and arguments properties of a Function object.

:

: Function arguments arguments arguments

arguments Function arguments TypeError

arguments

f f.arguments

() arguments null

ECMAScript Function.prototype arguments get set TypeError arguments Chrome Firefox Safari Function.prototype.arguments

js
(function f() {
  if (Object.hasOwn(f, "arguments")) {
    console.log(
      "arguments is an own property with descriptor",
      Object.getOwnPropertyDescriptor(f, "arguments"),
    );
  } else {
    console.log(
      "f doesn't have an own property named arguments. Trying to get f.[[Prototype]].arguments",
    );
    console.log(
      Object.getOwnPropertyDescriptor(
        Object.getPrototypeOf(f),
        "arguments",
      ).get.call(f),
    );
  }
})();

// In Chrome:
// arguments is an own property with descriptor {value: Arguments(0), writable: false, enumerable: false, configurable: false}

// In Firefox:
// f doesn't have an own property named arguments. Trying to get f.[[Prototype]].arguments
// Arguments {  }

arguments

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}`);

// :
// before: 1
// before: 0
// after: 0
// after: 1
// returned: null


Web Proxy Viewer  |  New URL  |  Original Page