1234567891011121314151617181920212223 |
- (function () {
- /**
- * abstract 与其他类差别不大
- * 抽象类不是为了实例化对象
- * 它是因为继承产生的
- */
- class Animal {
- constructor(name) {
- this.name = name;
- }
- }
- class Child3 extends Animal {
- say() {
- console.log(`你好${this.name}`);
- }
- }
- let c1 = new Child3("花花");
- console.log(c1);
- c1.say();
- // let a1 = new Animal('图图');
- // console.log(a1,'a1')
- // a1.say()
- })();
|