都会改变this的指向
用法不同
函数名/方法名.apply(对象,[参数1,参数2,......])
函数名/方法名call(对象,参数1,参数2,.....)
window.οnlοad=function()
{
function Person(name){
this.name=name;
}
Person.prototype.sum=function(num1,num2){
console.log((num1+num2)+this.name);
}
function Student(name){
this.name=name;
}
var per=new Person("xiaoming");
var stu=new Student("xiaoliang");
per.sum.apply(stu,[10,20]); //30xiaoliang
per.sum.call(stu,10,20); //30xiaoliang
}