Javascript 在Chrome中,JS绑定函数具有空参数。callee.caller
从Chrome 17开始,对于绑定函数,arguments.callee.caller似乎为null:Javascript 在Chrome中,JS绑定函数具有空参数。callee.caller,javascript,google-chrome,arguments,v8,ecmascript-5,Javascript,Google Chrome,Arguments,V8,Ecmascript 5,从Chrome 17开始,对于绑定函数,arguments.callee.caller似乎为null: function a() { this.test = function() { console.debug('*** ' + arguments.callee.caller); }; this.test(); // This prints the function this.bound = this.test.bind(this); this.bound(); // This
function a() {
this.test = function() { console.debug('*** ' + arguments.callee.caller); };
this.test(); // This prints the function
this.bound = this.test.bind(this);
this.bound(); // This prints null
}
绑定函数和未绑定函数过去一直起作用,但现在不再起作用
这是预期的行为吗 也许这不是一个错误。您可能会注意到:
如果函数f由顶级代码调用,则f.caller的值为null,否则调用f的就是函数。
当你在函数a中使用它时,'this'
意味着DOMWindow
。因此,当您将绑定函数绑定到此时,顶级代码会调用绑定函数。它返回null
愿它有帮助。rdtriny.
参数。不推荐使用被调用方和公司。他们在严格模式下抛出错误。我的猜测是,新版本的Chrome正在逐步淘汰它们。不过,我无法确认,因为我仍在16岁。您介意在上提交一个bug并在这里发布ID吗?我并不认为这个结果是错误的,但这可能是更改WebCore和V8之间的绑定的无意结果。