1.若干种情况下this的指向
(1)全局环境中指向window
<script>
console.log(this)
</script>
(2)普通函数中,若不是对象身上挂载的函数执行的时候依然指向window,若是对象上挂载的方法执行的时候则指向的对象,js严格模式下指向的则是undefined
2.bind、call、以及apply用法
首先明确bind、call、apply都是函数身上的方法
(1)bind用法
let testFun=function(){
console.log(this)
}
testFun()
testFun.bind(1)()
返回值:testFun.bind返回的函数依然是testFun本身,只是此时this的指向变成了括号内的参数1