The prototype of the key words in the front-end cultivation-javascript

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.