当前位置:网站首页>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
边栏推荐
- DHCP protocol instantiation analysis
- 【愚公系列】2022年06月 .NET架构班 079-分布式中间件 ScheduleMaster的集群原理
- It's really not human to let the express delivery arrive before the refund
- How to manage concurrent write operations? Get you started quickly
- [LeetCode每日一题] |686.重复叠加字符串匹配
- laravel8 实现签到功能案例
- postgresql创建表
- 09 Minimum Spanning Tree highway
- (湖南科技大学oj作业)问题 G: 串的模式匹配
- 【sql语句基础】——删(delete) /改(update)
猜你喜欢

Discussion on opengauss parallel decoding

Classmate, have you heard of mot?

Learn automatic testing of postman interface from 0 to 1

How to predict SQL statement query time?

Nat commun | language model can learn complex molecular distribution

时间复杂度与空间复杂度解析
![[daily question series]: how to test web forms?](/img/80/d0862275b547a7b5224d1c0effa779.jpg)
[daily question series]: how to test web forms?

收藏 |彻底搞懂感受野的含义与计算

laravel 监听模式

Step 4 of installation in RF: an error is reported when installing the robotframework-selenium 2library
随机推荐
Detailed explanation of MySQL binlog log and master-slave replication
Easy to use GS_ Dump and GS_ Dumpall command export data
Customized thread communication (lock) of JUC
Analysis of breadcrumb usage scenarios on websites
Maui introductory tutorial series (1. framework introduction)
Database design recommendations
Import data to the database? Try the copy from stdin statement
laravel 监听模式
How AGC security rules simplify user authorization and authentication requests
laravel 2020-01-01T00:00:00.000000Z 日期转化
【愚公系列】2022年06月 .NET架构班 079-分布式中间件 ScheduleMaster的集群原理
Go Language - value type and Reference Type
干掉 Swagger UI,这款神器更好用、更高效!
Memory optimization table mot management
Import data: GS_ restore or MERGE INTO? See which one suits you better
[Yugong series] June 2022 Net architecture class 076- execution principle of distributed middleware schedulemaster
GO语言数组和切片的区别
Using cloud DB to build app quick start - quick application
时间复杂度与空间复杂度解析
Selenium-- display waiting (medium) -- detailed explanation