当前位置:网站首页>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 .
边栏推荐
- The paid video at station B caused the up master to lose more than ten thousand fans
- 商城风格也可以很多变,DIY了解一下!
- MySQL installation tutorial
- 合宙Air32F103CBT6开发板上手报告
- 加载本地cifar10 数据集
- mysql整体架构和语句的执行流程
- When inputting text in the shutter textfield, if the page is refreshed, the cursor position will change.
- Introduction to database transactions
- Differences between = = and = = = in JS (detailed explanation)
- 地理位置数据存储方案——Redis GEO
猜你喜欢

DINO: DETR with Improved DeNoising Anchor Boxes for End-to-End Object Detection翻译

Sleep formula: how to cure bad sleep?

Principle analysis of ThreadLocal source code

不要小看了积分商城,它的作用可以很大!

基于神经标签搜索,中科院&微软亚研零样本多语言抽取式摘要入选ACL 2022

Lifeifei's team applied vit to the robot, increased the maximum speed of planning reasoning by 512 times, and also cued hekaiming's MAE

Lecun predicts AgI: big model and reinforcement learning are both ramps! My "world model" is the new way

Free books! AI across the Internet paints old photos. Here is a detailed tutorial!

appium服务的启动与关闭踩坑记录

赫尔辛基交通安全改善项目部署Velodyne Lidar智能基础设施解决方案
随机推荐
Constructor Pattern
[Third Party framework] retrofit2 (2) - add point configuration of network access framework
After flutter was upgraded from 2.2.3 to 2.5, the compilation of mixed projects became slower
TFIDF与BM25
Client development (electron) system level API usage 2
Detailed explanation of IVX low code platform series -- Overview (I)
Open the box to experience rust, come on!!!
Mt60b1g16hc-48b:a micron memory particles FBGA code d8bnk[easy to understand]
Tensorflow loading cifar10 dataset
异步处理容易出错的点
数据类型的内置方法
Advanced SQL statement 1 of Linux MySQL database
Flutter textfield setting can input multiple lines
What is OA
Desktop development (Tauri) opens the first chapter
JS add custom attributes to elements
Several ways of SQL optimization
Servlet详解
Traversal and branch judgment of JS (case on June 24, 2022)
数据存储和传输文件之XML使用和解析详解