[英]Why is this function being called?
I am trying to modify some behavior of a framework's JavaScript. 我正在尝试修改框架JavaScript的某些行为。 In IE10's developer tools under the View source drop down, there is a folder called Dynamic Scripts .
在IE10的开发人员工具中,“ 查看源”下的下拉菜单中有一个名为“ 动态脚本”的文件夹。 (Maybe someone could explain what Dynamic Scripts are?) And there is the following code under Function code (1089)
(也许有人可以解释什么是动态脚本?)在功能代码(1089)下有以下代码
This is the code: 这是代码:
function anonymous() {
var f=arguments.callee; return f._func.apply(f._owner, arguments);
}
And the first entry of the call stack is 调用堆栈的第一个条目是
Function code, Function code (1089), line 2
This line gets executed several times. 该行将执行多次。 But I don't know why.
但是我不知道为什么。
Who calls this line? 谁叫这条线?
The anonymous
function call does not mean a function called anonymous
. anonymous
函数调用并不意味着一个名为anonymous
的函数。 It is actually a name that is used to classify unnamed functions, like this one: 实际上,它是用于对未命名函数进行分类的名称,如下所示:
var anUnnamedFunc = function() {
return true;
};
If you referenced this function in a watch or console output, it would be dumped as an anonymous function. 如果您在监视或控制台输出中引用了此函数,则它将作为匿名函数转储。 To define a function that isn't anonymous, you would use:
要定义非匿名函数,可以使用:
var aNamedFunc = function namedFunction() {
return true;
};
The function being called in question, looks a lot like a bind
function. 正在调用的函数看起来很像
bind
函数。 That is a wrapper function used to create a function that binds arguments and or context to another function. 那是一个包装函数,用于创建将参数和/或上下文绑定到另一个函数的函数。 However, this version uses some sort of private property mechanism to bind arguments:
但是,此版本使用某种私有属性机制来绑定参数:
var bind = function() {
var f = arguments.callee;
return f._func.apply(f._owner, arguments);
};
I actually don't see what this sort of function would be used for, so wonder if it is just an anomaly of the IE debugger. 我实际上没有看到这种功能将用于什么功能,所以想知道它是否只是IE调试器的异常。 Try using a different browser and see if that function appears in the profile report.
尝试使用其他浏览器,看看该功能是否出现在配置文件报告中。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.