js call和apply方法
call()方法
call(obj,arg1,arg2...);
call()方法第一个参数是用作this的对象,其他参数直接传递给对象函数本身
例如:
function Cat(cColor){ this.color=cColor; this.showColor=function(){ alert(this.color); }}function TomCat(cColor){ Cat.apply(this,arguments);} var tom=new TomCat("black"); tom.showColor();