首页 > 其他 > 详细

面向对象class继承

时间:2021-05-07 00:01:33      阅读:28      评论:0      收藏:0      [点我收藏+]
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");

原型链:

技术分享图片

 

面向对象class继承

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

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!