使用频率 | 低 |
复杂程度 | 低 |
所属模块 | Function |
var func1 = function(){
if(this === window){
console.log("this is window")
}else{
console.log("this is " + this)
}
}
func1();
执行func1输出 : "this is window"
使用bind方法改变func1的this对象
var func2 = func1.bind("new");
func2()
执行func2输出 :"this is new"