JavaScript prototype chain

Source: Internet
Author: User

<!DOCTYPE HTML><HTMLLang= "en"><Head>    <MetaCharSet= "UTF-8">    <title></title>    <Scripttype= "Text/javascript">        /*function Person (name) {this.name = name}*/        var Person= function(name) { This. Name=name;        }; Person.prototype.getName= function(){            return  This. Name;        }; varOPerson01= NewPerson ('Fengyouqi');        Operson01.getname (); /** JS in the creation of objects (whether ordinary objects or function objects), there is a built-in property called _proto_, which is used to point to the prototype object of the function object that created it prototype * Console.log (operson01.__p roto__ = = = Person.prototype)//true **/Console.log (operson01.__proto__===Person.prototype); //true        /** Similarly, the Person.prototype object also has the _proto_ property, which points to the prototype * Console.log (object) of the function object that created it (Person.prototype.__pro to__ = = = Object.prototype)//true **/Console.log (person.prototype.__proto__===Object.prototype); //true        /** Continue, Object.prototype object also has _proto_ property, but it is more special, NULL * Console.log (OBJECT.PROTOTYPE.__PROTO__)//null * */Console.log (object.prototype.__proto__); //NULL        /** This chain that has _proto_ string up until Object.prototype._proto_ is called the prototype chain **/       </Script></Head><Body></Body></HTML>

Reference:

http://blog.csdn.net/i10630226/article/details/48689561

Http://www.cnblogs.com/dolphinX/p/4385862.html

Http://www.ruanyifeng.com/blog/2011/06/designing_ideas_of_inheritance_mechanism_in_javascript.html

JavaScript prototype chain

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.