注意是要延迟执行的函数中的this哦!!
//片段一 setTimeout("alert(this)", 1); // [object Window] //片段二 var obj = { say: function() { setTimeout("alert(‘in obj ‘ + this)", 0) } } obj.say(); //片段三 var obj = { say: function() { setTimeout(function(){alert(this)}, 0) } } obj.say(); //片段四 function talk() { alert(this); } var obj = { say: function() { setTimeout(talk, 0) } } obj.say();
时间: 2024-10-13 04:58:22