当前位置:网站首页>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
边栏推荐
- Markdown < a > tag new page open link
- Rédaction de thèses 19: différences entre les thèses de conférence et les thèses périodiques
- Handwritten Google's first generation distributed computing framework MapReduce
- ABAQUS script email auto notification
- Three. Based on ply format point cloud voxel model JS upload interface writing
- Remote code execution in Win 11 using wpad / PAC and JScript 3
- PCA based geometric feature calculation of PCL point cloud processing (52)
- NC basic usage 2
- Experience of mathematical modeling in 18 year research competition
- Leetcode dynamic planning training camp (1-5 days)
猜你喜欢
After route link navigation, the sub page does not display the navigation style problem
Installation and use of NVM
SQL Server connectors by thread pool 𞓜 instructions for dtsqlservertp plug-in
WordPress插件:WP-China-Yes解决国内访问官网慢的方法
【PTA】整除光棍
selenium.common.exceptions.WebDriverException: Message: ‘chromedriver‘ executable needs to be in PAT
CVPR 2022 | querydet: use cascaded sparse query to accelerate small target detection under high resolution
Tensorflow 2 basic operation dictionary
SQL Server Connectors By Thread Pool | DTSQLServerTP 插件使用说明
Es keyword sorting error reason = fielddata is disabled on text fields by default Set fielddata = true on keyword in order
随机推荐
Common form verification
Rédaction de thèses 19: différences entre les thèses de conférence et les thèses périodiques
波场DAO新物种下场,USDD如何破局稳定币市场?
Cadence Orcad Capture 批量更改元件封装功能介绍图文教程及视频演示
The market share of the financial industry exceeds 50%, and zdns has built a solid foundation for the financial technology network
[graph theory brush question-4] force deduction 778 Swimming in a rising pool
Local call feign interface message 404
Some basic configurations in interlij idea
论文写作 19: 会议论文与期刊论文的区别
Tencent Qiu Dongyang: techniques and ways of accelerating deep model reasoning
PCL点云处理之基于PCA的几何形状特征计算(五十二)
NC basic usage 2
R语言ggplot2可视化:ggplot2可视化散点图并使用geom_mark_ellipse函数在数据簇或数据分组的数据点周围添加椭圆进行注释
[talkative cloud native] load balancing - the passenger flow of small restaurants has increased
Investigate why close is required after sqlsession is used in mybatties
Error reported by Azkaban: Azkaban jobExecutor. utils. process. ProcessFailureException: Process exited with code 127
Five minutes to show you what JWT is
ABAQUS script email auto notification
SQL Server connectors by thread pool 𞓜 instructions for dtsqlservertp plug-in
SIGIR'22 "Microsoft" CTR estimation: using context information to promote feature representation learning