当前位置:网站首页>Thoroughly master prototype__ proto__、 Relationship before constructor (JS prototype, prototype chain)
Thoroughly master prototype__ proto__、 Relationship before constructor (JS prototype, prototype chain)
2022-07-02 14:35:00 【I haven't figured out the name yet*】
One 、 First map
Two 、prototype、proto、constructor The rules
Rule one : Instance does not prototype, Example of constructor Pointing constructor , Example of __proto__ Point to the prototype of the upper layer ( That is, the constructor prototype).
Rule 2 :Object、 Constructors 、Function All are Function Example .
example : Combine these two rules , In the picture f1 yes Foo Example ,Foo、Object、Function Are all Function Example . The direction is very clear .
Rule three : The prototype of the function __proto__ Point to the prototype of the upper layer ( That is to say Fun.prototype.proto Point to Object.prototype)
Rule 4 : The prototype of the function constructor Point to the function itself ( It can be understood as prototype and constructor Offset )
example : Combine the three four rules , The figure below also goes through .
3、 ... and 、 Code up
function Fun(){
}
const f1 = new Fun()
console.log(f1.constructor === Fun)
console.log(f1.__proto__ === Fun.prototype)
console.log(Function.prototype === Function.__proto__)
console.log(Fun.prototype.constructor === Fun)
console.log(Fun.prototype.__proto__ === Function.__proto__.__proto__)
console.log(Fun.constructor.__proto__ === Function.prototype)
console.log(Object.constructor === Function)
console.log(Function.constructor === Function)
console.log(Function.prototype.__proto__ === Object.prototype)
console.log(Object.prototype.__proto__ === null)
// The results are all true
summary : When the relationship in the picture has been printed in my mind , Try to write the transformation equation between the three by yourself , And various nesting .
for example :new Fun().constructor.proto.proto === Object.prototype
边栏推荐
- Available solution development oral arithmetic training machine / math treasure / children's oral arithmetic treasure / intelligent math treasure LCD LCD driver ic-vk1622 (lqfp64 package), original te
- C语言高级用法--函数指针:回调函数;转换表
- taobao.trades.sold.get-查询卖家已卖出的交易数据(根据创建时间),淘宝店铺卖出订单查询API接口,淘宝R2接口,淘宝oAuth2.0交易接口代码分享
- Check password
- kaggle如何使用utility script
- [Hongke technology sharing] how to test DNS server: DNS performance and response time test
- taobao.logistics.dummy.send( 无需物流发货处理 )接口,淘宝店铺发货API接口,淘宝订单发货接口,淘宝r2接口,淘宝oAu2.0接口
- 测试框架TestNG的使用(二):testNG xml的使用
- STM32 library function for GPIO initialization
- HMS core machine learning service helps zaful users to shop conveniently
猜你喜欢
Federated Search: all requirements in search
快解析:轻松实现共享上网
mathML转latex
A white hole formed by antineutrons produced by particle accelerators
Packet capturing tool Fiddler learning
Yyds dry goods inventory software encryption lock function
fatal: unsafe repository is owned by someone else 的解决方法
TeamTalk源码分析之win-client
复用和分用
没有从远程服务器‘‘映射到本地用户‘(null)/sa‘的远程用户‘sa‘及服务主密码解密错误的解决办法
随机推荐
Xilinx Vivado set *.svh as SystemVerilog Header
[to be continued] [UE4 notes] l5ue4 model import
Fabric. JS manual bold text iText
< schematic diagram of oral arithmetic exercise machine program development> oral arithmetic exercise machine / oral arithmetic treasure / children's math treasure / children's calculator LCD LCD driv
Quarkus learning IV - project development to deployment
<口算練習機 方案開發原理圖>口算練習機/口算寶/兒童數學寶/兒童計算器 LCD液晶顯示驅動IC-VK1621B,提供技術支持
Default slot, named slot, scope slot
Fabric.js 缩放画布
1、编辑利器vim
删除元素(带过渡动画)
PTA题库 ===>复数四则运算,一帮一,考试座位号(7-73)
Design and implementation of car query system based on php+mysql
Essential elements of science fiction 3D scenes - City
socket(套接字)与socket地址
A white hole formed by antineutrons produced by particle accelerators
天猫商品详情接口(APP,H5端)
[development environment] 010 editor tool (tool download | binary file analysis template template installation | shortcut key viewing and setting)
字符串匹配问题
Makefile 分隔文件名与后缀
Start to write a small demo - three piece chess