Both arguments.caller
and arguments.callee
make quite a few optimizations impossible so they were deprecated in latest
versions of JavaScript. In fact, EcmaScript 5 forbids the use of both in strict
mode, according to the docs:
Arguments objects for strict mode functions define non-configurable accessor properties named "caller" and "callee" which throw a TypeError
exception on access.
The same restriction applies to the function’s caller
and arguments
properties in strict
mode.
Noncompliant Code Example
function whoCalled() {
if (arguments.caller == null) //Noncompliant
console.log('I was called from the global scope.');
else
console.log(arguments.caller + ' called me!'); // Noncompliant
console.log(whoCalled.caller); // Noncompliant
console.log(whoCalled.arguments); // Noncompliant
}