apply的參數(shù)是array call沒有限制
obj.call(thisObj,arg1,arg2,...);
obj.apply(thisObj,[arg1,arg2,...]);
兩者作用一致,都是把obj(即this)綁定到thisObj,這時候thisObj具備了obj的屬性和方法?;蛘哒fthisObj繼承了obj的屬性和方法
var Parent = function(){
this.name = "yjc";
this.age = 22;
}
var child = {};
console.log(child);//Object {} ,空對象
Parent.call(child);
console.log(child); //Object {name: "yjc", age: 22}