如果是一般函数,this指向全局的对象window
在严格模式下“use strict”,this为undefind
3.如果是对象方法里面调用,this指向调用该方法的对象
4.构造函数里的this,指向创建出来的实例
改变this指向方式
1.call/apply改变this的指向并且执行调用函数
.call()
call(thisScope, arg1, arg2, arg3...)
.apply()
apply(thisScope, [arg1, arg2, arg3...]);两个参数
2.bind 改变this的指向,返回的是函数并不执行
.bind() bind(thisScope, arg1, arg2, arg3...)
- => 箭头函数的this由执行的上下文确定,箭头函数本身的this 是不存在的。