当前位置:网站首页>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
边栏推荐
- Fabric.js 动态设置字号大小
- ONNX+TensorRT:将预处理操作写入ONNX并完成TRT部署
- Who is better, Qianyuan projection Xiaoming Q1 pro or Jimi new play? Which configuration is higher than haqu K1?
- Fabric. JS zoom canvas
- 1. Editing weapon VIM
- 2、const 型指针
- Some interview suggestions for Android programmers "suggestions collection"
- 抓包工具fiddler学习
- There is no solution to the decryption error of the remote user 'sa' and the service master password mapped from the remote server 'to the local user' (null) /sa '
- taobao.logistics.dummy.send( 无需物流发货处理 )接口,淘宝店铺发货API接口,淘宝订单发货接口,淘宝r2接口,淘宝oAu2.0接口
猜你喜欢

Analysis of CPU surge in production environment service

快解析:轻松实现共享上网

Who is better, Qianyuan projection Xiaoming Q1 pro or Jimi new play? Which configuration is higher than haqu K1?

Fabric.js 自由绘制圆形

Daily learning 2

跨服务器数据访问的创建链接服务器方法

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

每日学习3

Design and implementation of car query system based on php+mysql

What is erdma? Popular science cartoon illustration
随机推荐
Fabric. JS upper dash, middle dash (strikethrough), underline
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
Fabric.js 上划线、中划线(删除线)、下划线
Teamtalk source code analysis win client
socket(套接字)与socket地址
STM32标准固件库函数名记忆(二)
TeamTalk源码分析之win-client
Xilinx Vivado set *.svh as SystemVerilog Header
Tujia muniao meituan has a discount match in summer. Will it be fragrant if the threshold is low?
threejs的控制器 立方体空间 基本控制器+惯性控制+飞行控制
实现一个多进程并发的服务器
4. Array pointer and pointer array
Convolutional neural network (Introduction)
Thymeleaf dependency
HMS core machine learning service helps zaful users to shop conveniently
threejs的控制器 立方體空間 基本控制器+慣性控制+飛行控制
Borui data integrated intelligent observable platform was selected into the "Yunyuan production catalogue" of China Academy of communications in 2022
大顶堆、小顶堆与堆排序
Fabric.js 缩放画布
Methods of software testing

