我们函数中经常会使用到 this 来指示变量,但 this 在不同情况下也有不同的含义,下面具体展示:
1、以函数形式调用函数时:fun(),this永远是夫对象,例如 JavaScript 中为 window
2、以方法调用时,this 永远是调用方法的对象,eg:tom.fun()中 this 就是 tom
3、以构造函数调用时, this 就是构造函数新创建的那个对象
4、使用 call()or apply()调用时,this 是指定的那个对象:fun.call(obj)中 this 就是obj