4.super.js 311 B

12345678910111213141516
  1. "use strict";
  2. (function () {
  3. class Animal {
  4. constructor(name) {
  5. this.name = name;
  6. }
  7. }
  8. class B extends Animal {
  9. constructor(name, age) {
  10. super(name);
  11. this.age = age;
  12. }
  13. }
  14. let b = new B("图图", 3);
  15. console.log(b);
  16. })();