面向对象class继承

1 class Student {
2             constructor(name) {
3                 this.name = name;
4             }
5             hello(){
6                 alert("hello");
7             }
8         }
9         var xiaoming = new Student("xiaoming");
 1  class Student {
 2             constructor(name) {
 3                 this.name = name;
 4             }
 5             hello(){
 6                 alert("hello");
 7             }
 8         }
 9 
10         class XiaoStudengt extends Student{
11             constructor(name,grade) {
12                 super(name);
13                 this.grade = grade;
14             }
15             myGrade(){
16                 alert('我是一名小学生')
17             }
18         }
19         var xiaoming = new Student("xiaoming");

原型链:

原文地址:https://www.cnblogs.com/YXBLOGXYY/p/14736956.html