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/03 Report--
Today, I will talk to you about the principle of JavaScript object prototype chain, which may not be well understood by many people. in order to make you understand better, the editor has summarized the following content for you. I hope you can get something according to this article.
A js object, in addition to its own properties, automatically generates proto, class, and extensible properties, where the proto property points to the prototype of the object.
Object properties also have configuration methods for writable, enumerable, configurable, value, and get/set.
There are three ways to create objects:
First, use literal quantity to create directly.
Second, it is based on the prototype chain.
To analyze the above figure, the main points are as follows:
1. You can create a new object with the new operator, and foo is a custom function, that is, the object.
two。 You can set properties on the foo.prototype.
3. The variable z is on the prototype chain and is a property of foo.prototype, not a property of obj.
4. The prototype chain is obj- > foo.prototype- > Object.prototype- > null.
To analyze the above figure, the main points are as follows:
1. If you define a variable with the same name as on the prototype chain, it does not overwrite the variable on the prototype chain, but adds a copy to the object itself.
The 2.delete operator does not affect the variables already on the prototype chain, but only removes the attributes of the object itself.
Third, use Object.create to create.
To analyze the above figure, the main points are as follows:
The 1.Object.create generates a new object based on the passed parameters, and the input parameter becomes part of its prototype chain.
The object created by 2.Object.create (null) points directly to null.
After reading the above, do you have any further understanding of the principle of JavaScript object prototype chain? If you want to know more knowledge or related content, please follow the industry information channel, thank you for your support.
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.