当前位置:网站首页>Prototype chain analysis
Prototype chain analysis
2022-06-25 16:06:00 【. calin.】
What is prototype chain
Objects have prototype objects ( The prototype object is described below ), Prototype objects have prototype objects , It forms a chain structure , It's called the prototype chain . The figure below is a partial structure of the prototype chain ( You can customize the person Constructor looks like ).
person Constructor through new person() Create examples P1,p1 Can pass -proto- Access its prototype object , Constructors can be constructed by prototype Property to access the prototype object , Prototype objects can also be created by constructor Access the constructor .
As object , The prototype object also has its prototype object ( Because all objects have prototype objects ), So you can also pass -proto- Access his prototype object , Here it is. Object, and Object The prototype object of is null.
The role of the prototype chain
For member lookup
When accessing members of an object , It is impossible to find whether the prototype object that will access it has this member
, Keep looking along the prototype chain , Know they're found , If it is not found, it will return undefined.
The role of prototype objects
stay ES5 front , Object - oriented programming is implemented through constructors and prototype objects , Using constructors has one drawback —— Objects created using constructors do not use the same method , It's a waste of memory . How to make these objects use the same method ? At this point, the prototype object will be used .
Every object can use prototype Property to access the prototype object , Members added to the prototype object can be accessed by the instance object created by the constructor .
边栏推荐
- Detailed explanation of IVX low code platform series -- Overview (I)
- JS notes
- Free books! AI across the Internet paints old photos. Here is a detailed tutorial!
- Alvaria宣布客户体验行业资深人士Jeff Cotten担任新首席执行官
- The database records are read through the system time under the Android system, causing the problem of incomplete Reading Records!
- SQL最常用的语句
- 一文带你搞懂 JWT 常见概念 & 优缺点
- 一行代码可以做什么?
- 异步处理容易出错的点
- Traversal and branch judgment of JS (case on June 24, 2022)
猜你喜欢
appium服务的启动与关闭踩坑记录
Free books! AI across the Internet paints old photos. Here is a detailed tutorial!
Golang uses Mongo driver operation - increase (Advanced)
Check whether the port number is occupied
GO语言-锁操作
Mixed density network (MDN) for multiple regression explanation and code example
Uncover gaussdb (for redis): comprehensive comparison of CODIS
Based on neural tag search, the multilingual abstracts of zero samples of Chinese Academy of Sciences and Microsoft Asiatic research were selected into ACL 2022
Advanced SQL statement 1 of Linux MySQL database
Overall MySQL architecture and statement execution process
随机推荐
Why does golang's modification of slice data affect the data of other slices?
Go language - lock operation
解析数仓lazyagg查询重写优化
报错:homebrew-core is a shallow clone
QC, QA, IPQC, JQE, DQA, SQE, DQC, MQC, IQC, FQC, OQC
Native JS dynamically add elements
The style of the mall can also change a lot. DIY can learn about it!
Time wheel and implementation analysis of time wheel in go zero
Flutter textfield setting can input multiple lines
Mark the same items in the Li list in red
什么是NFT数字藏品?
Continuously improve the overall performance of adaoracle Oracle Oracle
After flutter was upgraded from 2.2.3 to 2.5, the compilation of mixed projects became slower
Once the code was encrypted by the company's computer, the compilation failed
商城风格也可以很多变,DIY 了解一下!
Super comprehensive custom deep copy function
Uniapp converts graphic verification codes in the form of file streams into images
一文带你搞懂 JWT 常见概念 & 优缺点
Mixed density network (MDN) for multiple regression explanation and code example
Report on Hezhou air32f103cbt6 development board