Whenitcomestoinheritance,JavaScriptonlyhasoneconstruct:objects.Eachobjecthasaprivatepropertywhichholdsalinktoanotherobjectcalleditsprototype.Thatprototypeobjecthasaprototypeofitsown,andsoonuntilanobjectisreachedwithnullasitsprototype.Bydefinition,nullhasnoprototype,andactsasthefinallinkinthisprotot...
使用语法结构创建的对象 functionDuck(name){ varobj={ name:name, say:function(content){ console.log(content) } } returnobj;//返回一个对象 } varRoastDuck=Duck(RoastDuck);//实例化 RoastDuck.say("hhh");//调用 使用构造器创建的对象 functionDuck(){ this.name=[]; this.age=[]; } varRoastDuck=newDuck(); 使用Object.create创建的对象 ECMAScr...