Please note, this is a STATIC archive of website developer.mozilla.org from 03 Nov 2016, cach3.com does not collect or store any user information, there is no "phishing" involved.

ReferenceError: deprecated caller or arguments usage

この記事は編集レビューを必要としています。ぜひご協力ください

メッセージ

Warning: ReferenceError: deprecated caller usage (Firefox)
Warning: ReferenceError: deprecated arguments usage (Firefox)
TypeError: 'callee' and 'caller' cannot be accessed in strict mode. (Safari)

エラータイプ

strict モードでのみ、ReferenceError の警告が発生します。JavaScript の実行は、停止しません。

何がうまくいかなかったのか?

strict モード で、Function.callerFunction.arguments が使われていますが、それらは使用すべきではありません。なぜならば、それらは関数の呼び出し元をリークし、非標準で、最適化が困難、かつ性能に対して有害な機能のため、非推奨です。

非推奨の function.callerarguments.callee.caller

Function.callerarguments.callee.caller は非推奨です(詳細は参照記事を見てください)。

"use strict";

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

myFunc();
// Warning: ReferenceError: deprecated caller usage
// "The function was called from the top!"

Function.arguments

Function.arguments は非推奨です(詳細は参照記事を見てください)。

"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);
// Warning: ReferenceError: deprecated arguments usage

関連項目

ドキュメントのタグと貢献者

 このページの貢献者: YuichiNukiyama
 最終更新者: YuichiNukiyama,