【发布时间】:2016-10-28 15:50:26
【问题描述】:
我的回调和requestAnimationFrame 有一个非常奇怪的问题。一次成功执行,但第二次回调变成了数字。
function TEST () {
this.michou = "jean";
}
TEST.prototype.talk = function(fn) {
window.requestAnimationFrame(this.talk.bind(this));
alert(typeof fn); //type of callback
fn();
};
var jean = new TEST();
jean.talk(function() {
alert("hello");
});
如果您尝试此代码,您将在警报中看到“function”“hello”和“number”“number”。为什么callback的类型显示“数字”?
【问题讨论】:
标签: javascript callback numbers typeof requestanimationframe