this
call apply bind
相同
改变函数内部的 this 指向
区别
call,apply 会调用函数;而 bind 不会调用
call 接受若干参数,apply 接受一整个数组
应用
call 多用作继承
apply 多用于跟数组有关的操作,如求 max, min
bind 不调用函数,但会改变内部 this
this 指向
普通函数中的 this
谁调用了这个函数,this就指向谁
匿名函数的 this
匿名函数的 this 具有**全局性**,指向 window
箭头函数的 this
箭头函数的 this 是在定义时候确定下来的,而不是在调用时决定的
this 指向父级作用域的上下文
如何寻找箭头函数的 this 指向?
找到离箭头函数最近的function,与该function平级的执行上下文中的this即是箭头函数中的this
箭头函数无法使用 apply,call,bind 改变 this 指向
Last updated