1.普通函数 window
function go(){console.log(this);}
2.构造函数 实例对象
function Go(name,age){this.name=namethis.age=ageconsole.log(this);}var p=new Go('li',12)console.log(p);
3.对象方法
var name="window"var obj={name:"javascript",sayMame(){console.log(this.name); // javascript},wait(){setTimeout(function(){console.log(this,name); //window})},delay(){setTimeout(()=>{console.log(this.name); //javascript})}}obj.wait()obj.delay() //
4.事件绑定 绑定事件对象
var btn=document.querySelector('#btn')btn.onclick=function(){console.log(this);}
5.定时器函数
setTimeout(function(){console.log(this); //window})
