当前位置:网站首页>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>
边栏推荐
- pycharm新建项目
- 基于 FPGA 实现数字时钟详细原理讲解及验证结果
- Jincang database kingbasees client programming interface guide ODBC (5. Development process)
- Leetcode59. 螺旋矩阵 II
- 控件 圆角描边 MaterialShapeDrawable
- 双重for循环优化
- 简述分组密码的加密分组链接模式的工作原理及其特点(密码学移位密码加密解密)
- Worthington RNA determination detailed introduction
- hutool官网(hutool好用吗)
- 深度之眼(十八)——偏导数
猜你喜欢

解决:Direct local .aar file dependencies are not supported when building an AAR.

RHCE the next day

Machine learning problem notes

使用Pytorch快速训练网络模型

Worthington丨Worthington胰蛋白酶化学性质及相关研究

Multisensor fusion positioning (III) -- inertial technology

Tyrosine decarboxylase -- characteristics of tyrosine decarboxylase of Streptococcus faecalis in Worthington

Pycharm new project

【TA-霜狼_may-《百人计划》】美术2.2 模型基础

VMware VCSA 7.0 Install
随机推荐
Use pytoch to quickly train the network model
【C】atoi和offsetof的介绍和模拟实现
【C】喝汽水,找单身狗问题
请简述list,set,map类型的集合的各自特点(简述三种不同的继承方式下)
OpenCV宏定义
【C】逆序字符串(俩种递归思路)
After SAP Oracle replicates a new instance, the remote connection of the database reports an error ora-01031
Is the declarative code of compose so concise?
With the help of rpa+lcap, the enterprise treasurer management can be upgraded digitally
Leetcode 763. partition labels divide alphabetic intervals (medium)
VS2005透过SourceOffSite访问VSS2005的设置方法「建议收藏」
C语言 n*n矩阵求值及求逆矩阵[通俗易懂]
Websocket heartbeat mechanism (keep alive mechanism)
Powercli VMware vCenter deploys conventional new VMS in batch through self built PXE server with one click
CANoe应用案例之DoIP通信
1-4 类的复习
控件 圆角描边 MaterialShapeDrawable
多传感器融合定位(一)——3D激光里程计
DoIP测试开发实践
Briefly introduce the working principle and characteristics of block cipher encryption block link mode (cryptography shift cipher encryption and decryption)