JavaScript中call、apply个人理解
一句话即通俗的说:call、apply 是为了改变this的状态而存在的
}; } function personInfo(name,age){ this.name = name; this.age = age; } personInfo.prototype = { showInfo:function(){ console.log('我是'+this.name+','+'今年'+this.age+'岁。'); } } ); p.showInfo.apply(lisi); p.showInfo.call(lisi); p.showInfo.apply(zs); p.showInfo.call(zs);
结果: