当前位置:网站首页>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
prototypeAttributes 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
边栏推荐
- Building the tide, building the foundation and winning the future -- the successful holding of zdns Partner Conference
- 三十.什么是vm和vc?
- How can matlab obtain the truncated image in trainingimagelabeler
- Still using listview? Use animatedlist to make list elements move
- Why does ES6 need to introduce map when JS already has object type
- Rédaction de thèses 19: différences entre les thèses de conférence et les thèses périodiques
- WordPress插件:WP-China-Yes解决国内访问官网慢的方法
- redis 分布式锁
- Sqoop imports data from Mysql to HDFS using lzop compression format and reports NullPointerException
- CVPR 2022 | querydet: use cascaded sparse query to accelerate small target detection under high resolution
猜你喜欢
![[latex] 5 how to quickly write out the latex formula corresponding to the formula](/img/1f/3c5a332ce1d6852dde38040faea5bf.png)
[latex] 5 how to quickly write out the latex formula corresponding to the formula

Numpy Index & slice & iteration

16MySQL之DCL 中 COMMIT和ROllBACK

What is the difference between a host and a server?

The ODB model calculates the data and outputs it to excel

Operation of numpy array

selenium.common.exceptions.WebDriverException: Message: ‘chromedriver‘ executable needs to be in PAT

Recognition of high-speed road signs by Matlab using alexnet

【PTA】整除光棍

Fundamentals of network communication (LAN, Wan, IP address, port number, protocol, encapsulation and distribution)
随机推荐
中金财富公司怎么样,开户安全吗
Es error: request contains unrecognized parameter [ignore_throttled]
A useless confession artifact
The R language uses the timeroc package to calculate the multi time AUC value of survival data without competitive risk, and uses the confint function to calculate the confidence interval value of mul
Servlet learning notes
【目标跟踪】基于帧差法结合卡尔曼滤波实现行人姿态识别附matlab代码
Change the material of unity model as a whole
【PTA】L1-002 打印沙漏
Actual measurement of automatic ticket grabbing script of barley network based on selenium (the first part of the new year)
Introduction to link database function of cadence OrCAD capture CIS replacement components, graphic tutorial and video demonstration
BMP JPEG 图片转换为矢量图像 ContourTrace
PIP installation package reports an error. Could not find a version that satisfies the requirement pymysql (from versions: none)
Common form verification
三十.什么是vm和vc?
Customize timeline component styles
How about CICC fortune? Is it safe to open an account
Browser - learning notes
PCA based geometric feature calculation of PCL point cloud processing (52)
SQL Server connectors by thread pool 𞓜 instructions for dtsqlservertp plug-in
Leetcode dynamic planning training camp (1-5 days)