In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly introduces what the javascript prototype means. It is very detailed and has a certain reference value. Friends who are interested must finish it!
All JavaScript objects have a built-in Prototype private property that points to another object, which we call the prototype of the original object.
This article operating environment: windows7 system, javascript1.8.5 version, Dell G3 computer.
Learning objectives:
Know what js is prototype, prototype, constituent function, instance object relationship; prototype application scope.
What is a prototype?
The function has a prototype, and the function has a property called prototype. The prototype of the function points to an object, which is called the prototype object. The prototype object has a constructor property that points to the function itself.
There is also a prototype of the instance object, and the prototype object is generally called the _ _ proto__,__proto__ stealth prototype. This stealth prototype has a constructor attribute that points to the constructor that created the instance.
Direct relationship between constructor, instance object, and prototype
Relationship between constructor and instance object
There is also a constructor property in the _ _ proto__ in each instance object, which points to the constructor that created the instance:
The relationship between instance object _ _ proto__ and constructor prototype
In each instance object, the _ _ proto__ points to the constructor where the two prototype are equal.
Constructor, prototype prototype object, instance object, proto,constructor, direct relationship
Prototype function
One of the prototype functions: data sharing, saving memory space
The second part of the prototype function: in order to realize inheritance
How to share data and save memory space in prototype
JavaScript object-oriented programming
How does the prototype realize inheritance
For example, there is now a constructor for an "animal" object.
There is also a constructor for the cat object.
How can we make the cat inherit the animal?
If the cat's prototype object points to an instance of Animal, then all instances of the cat can inherit Animal.
The diagram of the relationship between cat1 instance object and constructor is as follows
Any prototype object has a constructor property that points to its constructor.
Add Cat.prototype = new Animal (); after the code
Cat.prototype.constructor points to Animal.
The diagram of the relationship between cat1 instance object and constructor is as follows
The above is all the content of the article "what does the javascript prototype mean?" Thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.