this 是谁1,this 在函数运行时才能确定2,谁调用了函数谁就是 this3,this 就是调用者例如var o1 = { name: ‘o1’,}var o2 = { name: ‘o2’,}o1.hello = function() { console.log(’this 是,’, this)}o2.hello = function() { console.log(’this 是, ‘, this)}o1.hello()o2.hello() o1 调用了 hello 函数,所以 hello 函数中的 this 就是 o1(调用者是 o1o2 同理什么是全局对象1,浏览器的全局对象是 window2,node.js 中全局对象是 global在浏览器中直接调用一个函数,那么 this 就是 window (调用者是 window例如var hello = function() { console.log(’this 是,’, this)}hello()apply call bind 的作用1,JavaScript 中函数是一个对象,所以函数可以有方法2,apply call bind 都是函数的方法,用来给函数指定 thisapply1,apply 接受两个参数2,第一个参数为函数里的 this3,第二个参数为要传给函数的参数列表,(这个参数列表可以当做是个数组来理解,实际上不是数组4,apply 会把这个参数列表拆成一个个的参数传给函数例如console.log.apply(console, arguments)这行代码把 log 函数的 this 指定为 cosnolevar arguments = [1, 2, 3]console.log.apply(console, arguments)// 相当于 console.log(1, 2, 3)callcall 和 apply 类似,区别是 call 只能把参数一个个传入例如console.log.call(console, 1, 2, 3)// 相当于 console.log(1, 2, 3)bind1,bind 只能返回一个函数让你调用2,bind 的第一个参数为函数里的 this3,bind 还可以有额外的参数例如var log = console.log.bind(console, ‘这里是额外参数’)log(‘hello’)