JS Senior understand at a glance what is the prototype chain

What is the prototype chain

To remember better programming principles, sometimes you need to do a piece hands. Remember that because a piece is easier to remember than the principle blunt, the following piece will teach us what is the prototype chain.

1) Xiaoming Xiaoming mother born dog puppies born mother. Xiao Ming and puppies are all object instances, while Xiao Ming mother and puppies mother is the prototype. The prototype is an object called a prototype object.

2) Xiao Ming Xiao Ming mother and father lovemaking session can give birth to a bunch of small obviously, puppy mom and dad puppy lovemaking session can give birth to a bunch of small dogs, Papa Pa is the constructor, commonly known as the made man-made or dog.

3) Xiao Ming mother will record information lovemaking session, so you can find information lovemaking session by Ma Xiaoming, that can find the prototype object constructor.

4) Xiao Ming mother can make lots of babies, but these babies only a mother, this is the uniqueness of the prototype.

5) Xiao Ming Xiao Ming mother is a mother's mother born, mom found by Xiao Ming Xiao Ming mother's mother, to find my mother ...... by Xiao Ming mother's mother, this relationship is called the prototype chain.

6) prototype chain is not infinite, when you have been looking up through Xiao Ming's mother finally found you will find ...... Xiao Ming mother's mother's mother is not a person, that is, the prototype chain final point to null.

7) human mother has someone who will look, the dog's mother gave birth to a dog have dog ugly, called inheritance.

8) You inherited your mother's skin color, your mother inherited your mother's mother's skin color, your mother's mother ...... This is the prototype inheritance chain.

9) You have no home, that your home refers to your mother's house; you have no home mother, that your home is your mother refers to her house ...... This is the search up the prototype chain.

10) You will inherit your mother look like, but you can also go to wash hair cut blow, that property of an object can be customized, it overrides the inherited property.

11) Although you wash cut blow dyed yellow hair, but you can not change the way your mother, your mother's brother and sister not to do with your yellow hair wash cut blow, that object instance can not change the properties of the prototype .

12) But you play your house is on fire, then that is your home your mother home your brother who were burned home, which is shared prototype property.

13) Your mother nicknamed Jane, Jane child neighbor aunt call you, but your mother made the hair from the Lion King Rejoice, ladies next door were changed to call your son Lion King, dynamic called the prototype.

14) the beauty of your mother, and went to South Korea plastic surgery, the whole into your mother can not recognize his mother, even if your mother in exchange Rejoice hair, but the next-door neighbor or the Lion King called you son. Because nobody recognize your mother, your mother after the plastic has been recycled recycling, and this is the prototype of a whole rewrite.

Guess you like

Origin www.cnblogs.com/caominjie/p/11335169.html