var obj = {
x: 81,
getX: function() {
console.log(this.x)
}
};
var getX = obj.getX.bind(obj);//use obj as 'this';
getX();//81
var getX = function(){
obj.getX.apply(obj);
}
getX();//also 81
L'uso di bind e call/applica ha un aspetto molto simile, voglio sapere qual è la differenza tra di loro. La funzione getX di cui sopra è la stessa?qual è la differenza tra "call/apply" e "bind"
Controllare http://stackoverflow.com/questions/1986896/what-is-the-difference- between betweencall -e-apply o http://stackoverflow.com/questions/15455009/js-call-apply-vs-bind – Rakesh