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.

caller

废弃的 arguments.caller 属性原先用在函数执行的时候调用自身。本属性已被移除且不再有用。

描述

arguments.caller 已经不可使用了,但是你还可以使用 Function.caller

function whoCalled() {
   if (whoCalled.caller == null)
      console.log('I was called from the global scope.');
   else
      console.log(whoCalled.caller + ' called me!');
}

示例

下例演示了arguments.caller属性的作用.

function whoCalled() {
   if (arguments.caller == null)
      console.log('该函数在全局作用域内被调用.');
   else
      console.log(arguments.caller + '调用了我!');
}

规范

无相关标准。JavaScript 1.1 实现,bug 7224 移除 caller,因为潜在的不安全性。

相关链接

文档标签和贡献者

 此页面的贡献者: Ende93, teoli, ziyunfei
 最后编辑者: Ende93,