Documentación offline JavaScript main

TypeError: 'caller', 'callee', and 'arguments' properties may not be accessed

main Documentación oficial Licencia CC-BY-SA-2.5Descargado el 2026-08-02

En esta página

The JavaScript strict mode-only exception "'caller', 'callee', and 'arguments' properties may not be accessed on strict mode functions or the arguments objects for calls to them" occurs when the deprecated {{jsxref("Functions/arguments/callee", "arguments.callee")}}, {{jsxref("Function.prototype.caller")}}, or {{jsxref("Function.prototype.arguments")}} properties are used.

Message#

TypeError: 'caller', 'callee', and 'arguments' properties may not be accessed on strict mode functions or the arguments objects for calls to them (V8-based & Firefox)
TypeError: 'arguments', 'callee', and 'caller' cannot be accessed in this context. (Safari)

Error type#

{{jsxref("TypeError")}} in strict mode only.

What went wrong?#

In strict mode, the {{jsxref("Functions/arguments/callee", "arguments.callee")}}, {{jsxref("Function.prototype.caller")}}, or {{jsxref("Function.prototype.arguments")}} properties are used and shouldn't be. They are deprecated, because they leak the function caller, are non-standard, hard to optimize and potentially a performance-harmful feature.

Examples#

Deprecated function.caller or arguments.callee#

{{jsxref("Function.prototype.caller")}} and arguments.callee are deprecated (see the reference articles for more information).

```js example-bad "use strict";

function myFunc() { if (myFunc.caller === null) { return "The function was called from the top!"; } return This function's caller was ${myFunc.caller}; }

myFunc(); // TypeError: 'caller', 'callee', and 'arguments' properties may not be accessed on strict mode functions or the arguments objects for calls to them

### Function.prototype.arguments

{{jsxref("Function.prototype.arguments")}} is deprecated (see the reference article for more
information).

```js example-bad
"use strict";

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}`);
// TypeError: 'caller', 'callee', and 'arguments' properties may not be accessed on strict mode functions or the arguments objects for calls to them

See also#