blob: 13128ec9622d7a93ab10435a560576e21b2d796a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
---
title: caller
slug: Web/JavaScript/Reference/Functions/arguments/caller
translation_of: Archive/Web/JavaScript/arguments.caller
---
<p>{{jsSidebar("Functions")}}</p>
<p><code><font face="Open Sans, Arial, sans-serif">废弃的 </font><strong>arguments.caller</strong></code> 属性原先用在函数执行的时候调用自身。本属性已被移除且不再有用。</p>
<h2 id="描述">描述</h2>
<p><code>arguments.caller 已经不可使用了,但是你还可以使用</code> {{jsxref("Function.caller")}}。</p>
<pre>function whoCalled() {
if (whoCalled.caller == null)
console.log('I was called from the global scope.');
else
console.log(whoCalled.caller + ' called me!');
}
</pre>
<h3 id="Examples" name="Examples">示例</h3>
<p>下例演示了<code>arguments.caller</code>属性的作用.</p>
<pre class="brush: js example-bad">function whoCalled() {
if (arguments.caller == null)
console.log('该函数在全局作用域内被调用.');
else
console.log(arguments.caller + '调用了我!');
}</pre>
<h2 id="规范">规范</h2>
<p>无相关标准。JavaScript 1.1 实现,{{bug(7224)}} 移除 caller,因为潜在的不安全性。</p>
<h2 id="浏览器支持">浏览器支持</h2>
<p>{{Compat("javascript.functions.arguments.caller")}}</p>
<h2 id="相关链接">相关链接</h2>
<ul>
<li>{{jsxref("Function")}}</li>
</ul>
|