当前位置:网站首页>XXXI` Prototype ` displays prototype properties and`__ proto__` Implicit prototype properties
XXXI` Prototype ` displays prototype properties and`__ proto__` Implicit prototype properties
2022-04-23 20:22:00 【Isn't this more popular than Bo people?】
This belongs to js Knowledge in .
1. js Several ways to create objects in (4 Kind of ) The way :
So let's see js Several ways to create objects in (4 Kind of ) The way :
- adopt Object() Method to create
- Create objects literally
- Create objects through custom functions
- Create objects through factory mode
Reference resources :https://blog.csdn.net/dearzhuoer/article/details/84574140
Let's take a look at the third way, and you'll know —— Create... Through functions !!!
What do you mean ? Functions are objects ? Pretty good !!!
2. Functions are objects ?
- stay js The object is the existence of God , Everything is the object ( Include function ), That's how you understand .
- Every function we create , The parser will add an attribute to the function
prototype
( Except for some built-in functions ). This property is a pointer , Points to a prototype object .( This attribute can also correspond to a prototype object ——prototype: Prototype object
) - If this function is a normal function , Then this
prototype
Attributes have no effect ; But if this function is used as a constructor to create an object , Then this object will have an implicit attribute__proto__
, This implied attribute__proto__
Also point to the prototype object .
So we have the following conclusions :Constructor name .prototype= Object name .__proto__
Reference resources :https://blog.csdn.net/dong001687/article/details/81836575
3. prototype
and __proto__
prototype
: Show prototype properties
__proto__
: Implicit prototype properties
As for why a display , An implicit , After reading the second point above, we also know .prototype
so ,__proto__
invisible .
4. give an example :
function Mytest(name,age){
this.name = name;
this.age = age;
}
var xiaoming = new Mytest(' Xiao Ming ',18)
console.log(Mytest.prototype) //{constructor: ƒ}
console.log(xiaoming.__proto__) //undefined
console.log(Mytest.prototype==xiaoming.__proto__) //true
版权声明
本文为[Isn't this more popular than Bo people?]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204232021100345.html
边栏推荐
- The second method of file upload in form form is implemented by fileitem class, servletfileupload class and diskfileitemfactory class.
- Redis的安装(CentOS7命令行安装)
- Redis installation (centos7 command line installation)
- R语言survival包coxph函数构建cox回归模型、ggrisk包ggrisk函数和two_scatter函数可视化Cox回归的风险评分图、解读风险评分图、基于LIRI数据集(基因数据集)
- DTMF双音多频信号仿真演示系统
- Cadence Orcad Capture 批量更改元件封装功能介绍图文教程及视频演示
- SQL Server connectors by thread pool 𞓜 instructions for dtsqlservertp plug-in
- 还在用 ListView?使用 AnimatedList 让列表元素动起来
- Three. Based on ply format point cloud voxel model JS upload interface writing
- 微信中金财富高端专区安全吗,证券如何开户呢
猜你喜欢
[graph theory brush question-5] Li Kou 1971 Find out if there is a path in the graph
【PTA】L1-002 打印沙漏
How to protect ECs from hacker attacks?
SQL Server Connectors By Thread Pool | DTSQLServerTP plugin instructions
LeetCode动态规划训练营(1~5天)
Plato Farm元宇宙IEO上线四大,链上交易颇高
Wave field Dao new species end up, how does usdd break the situation and stabilize the currency market?
波场DAO新物种下场,USDD如何破局稳定币市场?
【目标跟踪】基于帧差法结合卡尔曼滤波实现行人姿态识别附matlab代码
上海回应“面粉官网是非法网站”:疏于运维被“黑”,警方已立案
随机推荐
Scrapy教程 - (2)寫一個簡單爬蟲
Identification of bolt points in aerial photography based on perception
NC basic usage 2
PostgreSQL basic functions
Commit and rollback in DCL of 16 MySQL
Five minutes to show you what JWT is
Zdns was invited to attend the annual conference of Tencent cloud basic resources and share the 2020 domain name industry development report
Customize timeline component styles
上海回应“面粉官网是非法网站”:疏于运维被“黑”,警方已立案
SQL gets the latest record of the data table
SQL Server Connectors By Thread Pool | DTSQLServerTP plugin instructions
Cadence Orcad Capture CIS更换元器件之Link Database 功能介绍图文教程及视频演示
How can matlab obtain the truncated image in trainingimagelabeler
Redis installation (centos7 command line installation)
How to protect ECs from hacker attacks?
RT-1052学习笔记 - GPIO架构分析
CVPR 2022 | querydet: use cascaded sparse query to accelerate small target detection under high resolution
R language ggplot2 visualization: ggplot2 visualizes the scatter diagram and uses geom_ mark_ The ellipse function adds ellipses around data points of data clusters or data groups for annotation
R语言survival包coxph函数构建cox回归模型、ggrisk包ggrisk函数和two_scatter函数可视化Cox回归的风险评分图、解读风险评分图、基于LIRI数据集(基因数据集)
ABAQUS script email auto notification