123456789101112131415161718192021 |
- (function () {
- /***
- * 抽象类 与其他类差别不大
- * abstract
- * 抽象类不是为了实例化对象
- * 他是因为要继承而产生的
- */
- class Animal {
- constructor(name) {
- this.name = name;
- }
- }
- class Dog extends Animal {
- say() {
- console.log("我叫" + this.name);
- }
- }
- let dog1 = new Dog('旺财a');
- console.log(dog1, 'dog1');
- dog1.say();
- })();
|