我已经知道apply并且call是类似的功能集this(函数的上下文).
不同之处在于我们发送参数的方式(手动与数组)
题:
但什么时候应该使用这种 bind()方法?
var obj = {
x: 81,
getX: function() {
return this.x;
}
};
alert(obj.getX.bind(obj)());
alert(obj.getX.call(obj));
alert(obj.getX.apply(obj));
Run Code Online (Sandbox Code Playgroud)