当前位置:网站首页>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>
边栏推荐
- 商家对积分体系运营的两个误解
- Multi sensor fusion positioning (I) -- 3D laser odometer
- Connection pool - return connection details (Part 2)
- 以JSP为视图解析器搭建SSM项目
- Js判断数据类型的4种⽅式
- The failure rate is as high as 80%. How to correctly complete the strategic planning of digital transformation?
- Jincang database kingbasees client programming interface guide ODBC (2. Overview)
- Machine learning problem notes
- 剑指 Offer 55 - I. 二叉树的深度
- SAP oracle 复制新实例后数据库远程连接报错 ora-01031
猜你喜欢

NAT如何配置地址转换

YOLOV5学习笔记(一)——原理概述

深度之眼(十八)——偏导数

Pycharm configuring the running environment

Equipped with a new generation of ultra safe cellular batteries, Sihao aipao is available from 139900 yuan

Worthington - chemical properties and related studies of Worthington trypsin

Deep analysis of integrated learning gbdt

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

EN 1873 assembly accessories for roofing - plastic single roof lamps - CE certification

Leetcode59. 螺旋矩阵 II
随机推荐
EN 1935建筑五金.单轴铰链—CE认证
Leetcode63. 不同路径 II
失败率高达80%,数字化转型如何正确完成战略规划?
What is a driver signature and how does the driver get a digital signature?
[detailed and super simple] how to use websocket links
Worthington丨Worthington胰蛋白酶化学性质及相关研究
台式机dp接口在哪(主机没有dp接口怎么办)
SAP temporary tablespace error handling
Eight performance analysis indicators of effective supply chain management (Part 1)
EN 1935 building hardware. Single axis hinge - CE certification
Urease -- Characteristics and determination scheme of Worthington jack bean urease
多传感器融合定位(二)——基于地图的定位
Leetcode60. 排列序列
Pagoda phpMyAdmin unauthorized access vulnerability
Worthington核糖核酸酶B历史和化学性质说明
C language n*n matrix evaluation and inverse matrix [easy to understand]
Worthington丨Worthington胰蛋白酶抑制剂说明书
Hutool official website (is hutool easy to use)
Briefly introduce the working principle and characteristics of block cipher encryption block link mode (cryptography shift cipher encryption and decryption)
使用Pytorch快速训练网络模型