[ Web Proxy ]
URL:
Viewing: https://developer.mozilla.org/ko/docs/Web/JavaScript/Reference/Functions/arguments/callee [Back]  [Original]

arguments.callee - JavaScript | MDN

This page was translated from English by the community. Learn more and join the MDN Web Docs community.

View in English Always switch to English

arguments.callee

Deprecated

Avoid using this feature in new projects. JavaScript strict mode prohibits accessing arguments.callee. This feature may be a candidate for removal from web standards or browsers.

arguments.callee (property) .

In this article

callee arguments . (body) . , ( " " ) .

: ECMAScript 5(ES5) arguments.callee() . function (expression) function arguments.callee() .

arguments.callee ES5 ?

(olliej Stack Overflow )

JavaScript (named) . (recursive) .

, :

js
function factorial(n) {
  return !(n > 1) ? 1 : factorial(n - 1) * n;
}

[1, 2, 3, 4, 5].map(factorial);

:

js
[1, 2, 3, 4, 5].map(function (n) {
  return !(n > 1) ? 1 : /* what goes here? */ (n - 1) * n;
});

. arguments.callee

js
[1, 2, 3, 4, 5].map(function (n) {
  return !(n > 1) ? 1 : arguments.callee(n - 1) * n;
});

, . ( arguments, callee caller ) tail (tracing .) this . :

js
var global = this;

var sillyFunction = function (recursed) {
  if (!recursed) {
    return arguments.callee(true);
  }
  if (this !== global) {
    alert("This is: " + this);
  } else {
    alert("This is the global");
  }
};

sillyFunction();

ECMAScript 3 (named) . :

js
[1, 2, 3, 4, 5].map(function factorial(n) {
  return !(n > 1) ? 1 : factorial(n - 1) * n;
});

:

  • (outer scope) (IE 8 )
  • arguments

arguments.callee.caller Function.caller. ? , caller : . , f (unknown) , f . guard :

js
function f(a, b, c, d, e) {
  return a ? b * c : d * e;
}

JavaScript , . . . .

arguments.callee

. , . , ( Function ) . , arguments.callee .

. .

js
function create() {
  return function (n) {
    if (n <= 1) return 1;
    return n * arguments.callee(n - 1);
  };
}

var result = create()(5); //  120 (5 * 4 * 3 * 2 * 1)

arguments.callee

, arguments.callee . (deprecation) (Firefox bug 725398 ):

js
function createPerson(sIdentity) {
  var oPerson = new Function("alert(arguments.callee.identity);");
  oPerson.identity = sIdentity;
  return oPerson;
}

var john = createPerson("John Smith");

john();

Specification
ECMAScript 2027 LanguageSpecification
# sec-arguments-exotic-objects


Web Proxy Viewer  |  New URL  |  Original Page