in general, the object in JavaScript is a pointer to prototype and a list of its own properties. only the constructor (object,function,array,date,string) has and will have a prototype property. The prototype chain inheritance is the creation of a new pointer to the constructor's prototype property.
The prototype property list defaults to a constructor (constructor) property, which is a pointer to the prototype property, which is the current object itself.
1 function BaseClass ()2 {3 This. showmsg =function ()4 {5Alert"baseclass::showmsg"); 6 }7 8 This. baseshowmsg =function ()9 {TenAlert"baseclass::baseshowmsg"); One } A } -Baseclass.showmsg =function () - { theAlert"baseclass::showmsg Static"); - } - - function Extendclass () + { - This. showmsg =function () + { AAlert"extendclass::showmsg"); at } - } -Extendclass.showmsg =function () - { -Alert"extendclass::showmsg Static") - } in -Extendclass.prototype =NewBaseClass (); to varInstance =NewExtendclass (); + -Instance.showmsg ();//Show Extendclass::showmsg theInstance.baseshowmsg ();//Show Baseclass::baseshowmsg *Instance.showmsg ();//Show Extendclass::showmsg $ Panax NotoginsengBaseClass.showMsg.call (instance);//Show baseclass::showmsg Static - the varBaseinstance =NewBaseClass (); +Baseinstance.showMsg.call (instance);//Show Baseclass::showmsg
The prototype of the key words in the front-end cultivation-javascript