5.接口.js 588 B

123456789101112131415161718192021
  1. "use strict";
  2. (function () {
  3. /**
  4. * 类型别名 接口区别
  5. * 接口:偏向 对象/结构的定义 可扩展 可合并
  6. * 类型别名:偏向于任意类型 联合/交叉类型 简单的别名
  7. * */
  8. // 类实现接口 需要继承
  9. // 类型约束
  10. class List {
  11. constructor(name, age, address, sex, x) {
  12. this.name = name;
  13. this.age = age;
  14. this.address = address;
  15. this.sex = sex;
  16. this.x = x;
  17. }
  18. }
  19. let x = new List('图图', 3, '上海', '12');
  20. console.log(x);
  21. })();