当前位置:网站首页>Review of categories 1-4
Review of categories 1-4
2022-07-28 23:59:00 【Endless cakes】
Class review
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title> class </title>
</head>
<body>
<script type="text/javascript">
/*
summary :
1. Constructors in classes don't have to be written , To initialize an instance , If the specified attribute is added, write .
2. If A Class inherited B class , And A The constructor is written in the class , that A In class constructors super It has to be called .
3. Methods defined in class , They are all placed on the prototype object of the class , Called by an instance object of a class .
*/
// Create a class
class Person{
// Constructor method
constructor(name,age){
this.name = name
this.age = age
}
// General method
//speak Methods are placed on the prototype object of the class , For example
// adopt Person The instance speak when ,speak Medium this Namely Person example
speak(){
console.log(` My name is ${this.name}, Age ${this.age} year `)
}
}
// Create a student class
class Student extends Person{
constructor(name,age,grade){
super(name,age)
this.grade = grade
}
speak(){
console.log(` My name is ${this.name}, Age ${this.age} year , I read ${this.grade} grade `)
}
study(){
console.log(' I study very hard ')
}
}
const s1 = new Student('xiaozhg',15,' higher ')
s1.speak()
s1.study()
</script>
</body>
</html>
边栏推荐
猜你喜欢
Apple's official website is being updated to maintain the apple store. Products such as the iPhone 13 / pro of the Bank of China will enjoy a maximum discount of 600 yuan
DoIP测试开发实践
E-commerce data model design
NAT如何配置地址转换
智能垃圾桶(七)——SG90舵机的介绍与使用(树莓派pico实现)
PowerCL 批量创建及管理虚拟交换机
Zabbix 5.0 使用自带Redis模版监控
JS高级 之 ES6~ES13 新特性
Worthington丨STEMxyme的分类和测定方法
The failure rate is as high as 80%. How to correctly complete the strategic planning of digital transformation?
随机推荐
脲酶丨Worthington杰克豆脲酶的特性及测定方案
Explanation of history and chemical properties of Worthington ribonuclease B
Do you know any formal part-time platforms?
Zero view h5s video platform getUserInfo information disclosure vulnerability cnvd-2020-67113
数仓:Doris在美团的应用实践
EN 12101-8:2011烟雾和热量控制系统防烟挡板—CE认证
Multi sensor fusion positioning (I) -- 3D laser odometer
DevOps在物联网解决方案中的应用
基因组 DNA 分离丨Worthington核糖核酸酶A
控件 圆角描边 MaterialShapeDrawable
Apple's official website is being updated to maintain the apple store. Products such as the iPhone 13 / pro of the Bank of China will enjoy a maximum discount of 600 yuan
Jincang database kingbasees client programming interface guide ODBC (5. Development process)
解决:Direct local .aar file dependencies are not supported when building an AAR.
PMP考试倒计时,速看3A通关锦囊!
Create AP hotspots for imx6 development board QT system based on rtl8723 cross compile iptables
深度之眼(十八)——偏导数
Leetcode61. 旋转链表
Yolov5 learning notes (I) -- principle overview
尿酸酶丨Worthington猪肝尿酸酶的特征:
EN 12101-8:2011 smoke dampers for smoke and heat control systems - CE certification