借鉴自:https://www.zhihu.com/question/20289071
function der(a,b){
return a - b;
}
function add(a,b){
return a + b;
}
console.log(add.call(der,1,2)); //3
console.log(add.call(der,1,2)==add(1,2)); //true
function cat(){
}
cat.prototype={
food:"fish",
say: function(){
alert("I love "+this.food);
}
}
var blackCat = new cat;
blackCat.say();
whiteDog = {food:"bone"};
blackCat.say.call(whiteDog); //通过call(),额可以赋予whiteDog对象blackCat对象的属性。