6.接口.js 561 B

1234567891011121314151617181920212223
  1. "use strict";
  2. (function () {
  3. // 类型别名 定义数据
  4. const obj = {
  5. name: "孙悟空",
  6. age: 20,
  7. };
  8. // 继承 extends
  9. // 接口 interface implements
  10. class Person {
  11. constructor(name, age, sex, num) {
  12. this.name = name;
  13. this.age = age;
  14. this.num = num;
  15. this.sex = sex;
  16. }
  17. say() {
  18. console.log(this.name, this.age, this.num, this.sex, '我是个好人');
  19. }
  20. }
  21. let a = new Person("猪八戒", 20, "男", 1);
  22. a.say();
  23. })();