參考連接http://www.w3school.com.cn/js/pro_js_inheritance_implementing.asp
//對象冒充 function classA (color){ this.color = color; this.sayColor = function(){ console.log(color); }; this.sayOnther = function(){ console.log(color+"2") }; } function classB (color,name){ this.syaColor = classA; this.syaColor(color); delete this.newMethod; this.name = name; this.sayName = function(){ console.log(name); }; } var a = new classA("red"); var b = new classB("blue","noin"); //a.sayColor(); //b.sayColor(); //b.sayName(); //call()方法與apply()效果同樣 function classC(color,name){ classA.call(this,color);//call方法 //classA.apply(this,new Array(color));//apply方法 } var c = new classC("yellow","noin"); c.sayColor(); c.sayOnther();