原型式繼承:function object(o){ function clone(){};
clone.prototype=o; return new clone();
}function parent(name){ this.position=1; this.name=name;
}parent.prototype.getLevel=function(){ console.log("hello");
}var children=object(parent);這時運行:children.getLevel(); //children.getLevel is not a function(…)children.prototype.getLevel();//hello為什么會產生兩種不同的結果?
object.method() 和 object.prototype.method();
慕森卡
2018-09-26 06:07:58