当前位置:网站首页>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>
边栏推荐
- 简述分组密码的加密分组链接模式的工作原理及其特点(密码学移位密码加密解密)
- Deep analysis of integrated learning AdaBoost
- Genomic DNA isolation Worthington ribonuclease A
- 1-8 props的基础使用
- Leetcode 763. partition labels divide alphabetic intervals (medium)
- Oracle创建表空间和用户
- 实时数仓:美团点评Flink的实时数仓应用分享
- Jincang database kingbasees client programming interface guide ODBC (5. Development process)
- Multi sensor fusion positioning (I) -- 3D laser odometer
- Arm-A53资料「建议收藏」
猜你喜欢

多传感器融合定位(一)——3D激光里程计

EN 1935 building hardware. Single axis hinge - CE certification

pycharm配置运行环境

Compose 的声明式代码如此简洁?

PHP 海报二维码合成

Explanation of history and chemical properties of Worthington ribonuclease B

pycharm新建项目

Worthington - chemical properties and related studies of Worthington trypsin

【C】喝汽水,找单身狗问题

Leetcode62. 不同路径
随机推荐
Jincang database kingbasees client programming interface guide ODBC (2. Overview)
DoIP测试开发实践
pip镜像下载
基于 FPGA 实现数字时钟详细原理讲解及验证结果
AUTOCAD——Excel表格导入CAD、CAD合并两兄弟
Yolov5 learning notes (I) -- principle overview
Wildcard ssl/tls certificate
Eight performance analysis indicators of effective supply chain management (Part 1)
实时数仓:美团基于Flink的实时数仓建设实施
Worthington丨Worthington胰蛋白酶化学性质及相关研究
VMware VCSA 7.0 Install
Arm-A53资料「建议收藏」
通配符 SSL/TLS 证书
控件 圆角描边 MaterialShapeDrawable
Codeforces Round #810 (Div. 2) A - C
失败率高达80%,数字化转型如何正确完成战略规划?
你知道有哪些正规的兼职平台吗?
ISO 13400(DoIP)标准解读
Do you know any formal part-time platforms?
Multisensor fusion positioning (III) -- inertial technology