当前位置:网站首页>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
边栏推荐
- 大顶堆、小顶堆与堆排序
- 抓包工具fiddler学习
- <口算练习机 方案开发原理图>口算练习机/口算宝/儿童数学宝/儿童计算器 LCD液晶显示驱动IC-VK1621B,提供技术支持
- C语言高级用法--函数指针:回调函数;转换表
- Yyds dry goods inventory software encryption lock function
- NLA natural language analysis makes data analysis more intelligent
- Fabric.js 自由绘制椭圆
- The evolution process of the correct implementation principle of redis distributed lock and the summary of redison's actual combat
- Advanced usage of C language -- function pointer: callback function; Conversion table
- Borui data integrated intelligent observable platform was selected into the "Yunyuan production catalogue" of China Academy of communications in 2022
猜你喜欢
MQ教程 | Exchange(交换机)
Fabric.js 上划线、中划线(删除线)、下划线
Fabric.js 缩放画布
[development environment] Dell computer system reinstallation (download Dell OS recovery tool | use Dell OS recovery tool to make USB flash disk system | install system)
Borui data integrated intelligent observable platform was selected into the "Yunyuan production catalogue" of China Academy of communications in 2022
复用和分用
快解析:轻松实现共享上网
PHP linked list creation and traversal
Yolov3 & yolov5 output result description
途家木鸟美团夏日折扣对垒,门槛低就一定香吗?
随机推荐
STM32标准固件库函数名记忆(二)
Delete element (with transition animation)
Tujia muniao meituan has a discount match in summer. Will it be fragrant if the threshold is low?
Makefile 分隔文件名与后缀
Fabric.js 自由绘制椭圆
PyQt5_ Qscrollarea content is saved as a picture
MQ tutorial | exchange (switch)
提示:SQL Server 阻止了对组件‘Ad Hoc Distributed Queries ‘的STATEMENT ‘OpenRowset/OpenDatasource“”
数据库连接池和数据源
STM32 library function for GPIO initialization
threejs的控制器 立方体空间 基本控制器+惯性控制+飞行控制
求轮廓最大内接圆
PTA题库 ===>复数四则运算,一帮一,考试座位号(7-73)
OpenCV调用USB摄像头的点滴
微信小程序使用towxml显示公式
Design and implementation of car query system based on php+mysql
Quarkus learning IV - project development to deployment
报错:npm WARN config global `--global`, `--local` are deprecated. Use `--location=global` instead.
threejs的控制器 立方體空間 基本控制器+慣性控制+飛行控制
关于Flink框架窗口(window)函数最全解析