window.onload = function(){ manager.init(); }; var manager = { init: function() { slef = this; this.name = "manager"; setInterval(this.timerMonitor, 1000); }, timerMonitor: function(){ console.log(this.name); } }
window.onload = function(){ manager.init(); }; var manager = { init: function() { self=this; this.name = "manager"; setInterval(function(){self.timerMonitor()}, 1000); }, timerMonitor: function(){ console.log(this.name); } }
再來看Chrome下的運行結果以下圖:chrome