当前位置:网站首页>Class and__ proto__ Property, the class prototype chain has two inheritance routes
Class and__ proto__ Property, the class prototype chain has two inheritance routes
2022-06-11 16:09:00 【imkaifan】
Two day inheritance route of class : Class as an object __proto__ attribute ;Class Syntax sugar as a constructor , At the same time there is prototype Properties and __proto__ attribute ;
(1) A subclass __proto__ attribute , Represents the inheritance of the constructor , Always point to the parent class .
(2) Subclass prototype Attribute __proto__ attribute , Represents the inheritance of methods , Always point to the parent prototype attribute .
class Person {
constructor(name, sex) {
this.name = name;
this.sex = sex;
}
say() {
return ('lalalala' + this.name)
}
}
Person.color = 'red'
class PersonOther extends Person {
constructor(x,y) {
super(x,y)
}
}
console.log(PersonOther.__proto__ === Person) // true // Prototype chain formation
console.log(PersonOther.prototype.__proto__ === Person.prototype) // true // Prototype chain formation
console.log(PersonOther.color) // red Class integration static attributes are not used by instances , Only static attributes between classes implement inheritance
let kate = new PersonOther('kate', 'woman')
console.log(kate.name, kate.sex) // kate woman
console.log(kate.color) // undefined
console.log(kate.say()) // lalalala kate
边栏推荐
- Tianjin Port coke wharf hand in hand map flapping software to visually unlock the smart coke port
- Understand the dense support functions / stored procedures of opengauss
- Database resource load management (Part 2)
- 搜索与图论:Dijkstra求最短路 I—Dijkstra(最短路径)
- dapr 思维导图
- GO语言-Slice切片
- MySQL快速入门实例篇(入内不亏)
- Selenium-- display waiting (medium) -- detailed explanation
- Go language - array
- Collect | thoroughly understand the meaning and calculation of receptive field
猜你喜欢

Cloud data management will break the island of storage and the island of team
![[Yugong series] June 2022 Net architecture class 078 worker cluster of distributed middleware schedulemaster](/img/73/5636ba7a0772c4f9e2d1174df40839.png)
[Yugong series] June 2022 Net architecture class 078 worker cluster of distributed middleware schedulemaster

电脑下面的任务栏怎么显示打开的程序

书籍《阅读的方法》读后感

Deep separable convolution

rf中安装的第四步:安装 robotframework-selenium2library报错

Step 4 of installation in RF: an error is reported when installing the robotframework-selenium 2library

Overview and example analysis of opengauss database performance tuning

AI tool for cutting-edge technology exploration: analog detection

面试经典题目:怎么做的性能测试?【杭州多测师】【杭州多测师_王sir】
随机推荐
[daily question series]: how to test web forms?
Detailed explanation of MySQL binlog log and master-slave replication
收藏 | 可解释机器学习发展和常见方法!
Laravel 8 uses passport for auth authentication and token issuance
CLP information - No. 1 central document on Strengthening Rural Revitalization financial services
Data enhancement
[Yugong series] June 2022 Net architecture class 078 worker cluster of distributed middleware schedulemaster
Operation guide | how to select a collector on moonbeam and Moonriver
postgresql创建数据库
Learn automatic testing of postman interface from 0 to 1
PostgreSQL create table
Go Language - value type and Reference Type
Thales cloud security report shows that cloud data leakage and complexity are on the rise
Maui introductory tutorial series (1. framework introduction)
postgresql源码编译
Using cloud DB to build app quick start - quick application
干掉 Swagger UI,这款神器更好用、更高效!
【愚公系列】2022年06月 .NET架构班 077-分布式中间件 ScheduleMaster加载程序集定时任务
3000 words to teach you how to use mot
Princeton Dengjia student's personal account: must I have a doctorate? No, I can also be an applied scientist in a large factory as an undergraduate