当前位置:网站首页>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
边栏推荐
- Historical track data reading of Holux m1200-e Bluetooth GPS track recorder
- Numpy mathematical function & logical function
- Automatically fill in body temperature and win10 task plan
- Fundamentals of network communication (LAN, Wan, IP address, port number, protocol, encapsulation and distribution)
- Remote code execution in Win 11 using wpad / PAC and JScript
- R language uses timeroc package to calculate the multi time AUC value of survival data under competitive risk, uses Cox model and adds covariates, and R language uses the plotauccurve function of time
- On BIM data redundancy theory
- Experience of mathematical modeling in 18 year research competition
- Don't bother tensorflow learning notes (10-12) -- Constructing a simple neural network and its visualization
- Implementation of mypromise
猜你喜欢
After route link navigation, the sub page does not display the navigation style problem
Handwritten Google's first generation distributed computing framework MapReduce
Numpy mathematical function & logical function
SQL Server Connectors By Thread Pool | DTSQLServerTP plugin instructions
【PTA】整除光棍
WordPress插件:WP-China-Yes解决国内访问官网慢的方法
Latest investigation and progress of building intelligence based on sati
堡垒机、跳板机JumpServer的搭建,以及使用,图文详细
Recognition of high-speed road signs by Matlab using alexnet
Plato Farm元宇宙IEO上线四大,链上交易颇高
随机推荐
Sqoop imports data from Mysql to HDFS using lzop compression format and reports NullPointerException
AQS learning
Is the wechat CICC wealth high-end zone safe? How to open an account for securities
R语言使用timeROC包计算无竞争风险情况下的生存资料多时间AUC值、使用confint函数计算无竞争风险情况下的生存资料多时间AUC指标的置信区间值
A useless confession artifact
SQL Server connectors by thread pool 𞓜 instructions for dtsqlservertp plug-in
NC basic usage 3
On BIM data redundancy theory
[graph theory brush question-5] Li Kou 1971 Find out if there is a path in the graph
Solution to PowerDesigner's failure to connect to MySQL in x64 system
Scrapy教程 - (2)寫一個簡單爬蟲
Linux64Bit下安装MySQL5.6-不能修改root密码
JDBC tool class jdbcfiledateutil uploads files and date format conversion, including the latest, simplest and easiest way to upload single files and multiple files
Historical track data reading of Holux m1200-e Bluetooth GPS track recorder
Mysql database backup scheme
JDBC database addition, deletion, query and modification tool class
The flinkcdc reports an error: but this is no longer available on the server
R语言ggplot2可视化分面图(facet_wrap)、使用lineheight参数自定义设置分面图标签栏(灰色标签栏)的高度
Paper writing 19: the difference between conference papers and journal papers
[graph theory brush question-4] force deduction 778 Swimming in a rising pool