这是让我感到困惑的代码片段:
var timer =
{
start: function()
{
var self = this;
/*Why the code below doesn't write to this:
window.setInterval(self.tick, 1000).*/
//Instead, it embedded into a function like this:
window.setInterval(function(){self.tick();}, 1000)
},
tick: function()
{
console.log("tick!");
}
}
timer.start();