当前位置:网站首页>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
边栏推荐
- Golang 快速生成数据库表的 model 和 queryset
- obsidian安装第三方插件——无法加载插件
- Xilinx Vivado set *.svh as SystemVerilog Header
- Quick analysis: easy to share the Internet
- 数据湖(十一):Iceberg表数据组织与查询
- 报错:npm WARN config global `--global`, `--local` are deprecated. Use `--location=global` instead.
- Route (II)
- Fabric.js 手动加粗文本iText
- Understanding of mongodb
- Adhere to the foundation of 20 minutes go every day II
猜你喜欢

YoloV6训练:训练自己数据集遇到的各种问题

Daily learning 3

< 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

QT new project

STM32库函数进行GPIO初始化

Use of swagger

Certik released the defi security report in 2021, disclosing key data of industry development (PDF download link attached)

Makefile 分隔文件名与后缀

TeamTalk源码分析之win-client

Who is better, Qianyuan projection Xiaoming Q1 pro or Jimi new play? Which configuration is higher than haqu K1?
随机推荐
每日学习2
Fabric. JS free draw circle
Golang quickly generates model and queryset of database tables
腾讯云 TStor 统一存储通过信通院首批文件存储基础能力评测
Fabric. JS dynamically set font size
软件测试的方法
富文本编辑器添加矢量公式(MathType for TinyMCE ,可视化添加)
数据库连接池和数据源
< 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
Analysis of CPU surge in production environment service
Yolov3 & yolov5 output result description
Fabric. JS zoom canvas
测试框架TestNG的使用(二):testNG xml的使用
PHP linked list creation and traversal
The most complete analysis of Flink frame window function
检查密码
联合搜索:搜索中的所有需求
关于Flink框架窗口(window)函数最全解析
一张图彻底掌握prototype、__proto__、constructor之前的关系(JS原型、原型链)
Chapter 9: xshell free version installation

