@@ -0,0 +1,23 @@
+"use strict";
+(function () {
+ class Animal {
+ constructor(name, sex) {
+ this.name = name;
+ this.sex = sex;
+ }
+ eat() {
+ console.log("吃东西");
+ class Cat extends Animal {
+ constructor(name, sex, age) {
+ super(name, sex);
+ this.age = age;
+ let c = new Cat('淼淼', '女', 3);
+ console.log(c.name);
+ console.log(c.sex);
+ console.log(c.age);
+ c.eat();
+})();
@@ -0,0 +1,12 @@
+ class Person2 {
+ constructor(name, age, color) {
+ this.age1 = age;
+ this.color = color;
+ let p3 = new Person2('图图', 3, '红');
+ console.log(p3);
@@ -6,6 +6,6 @@
<title>Document</title>
</head>
<body>
- <script src="./3.继承.js"></script>
+ <script src="./5.接口.js"></script>
</body>
</html>
@@ -0,0 +1,25 @@
+(function() {
+ class Animal{
+ name:string;
+ sex: string;
+ constructor(name:string,sex:string) {
+ console.log("吃东西")
+ age:number;
+ constructor(name:string,sex:string,age:number) {
+ super(name,sex);
+ let c = new Cat('淼淼','女',3);
+ c.eat()
+})()
@@ -0,0 +1,19 @@
+ // 接口 定义数据类型的规范
+ interface vase {
+ name: string,
+ age1: number
+ class Person2 implements vase {
+ age1: number;
+ color: string;
+ constructor(name:string,age:number,color:string) {
+ let p3 = new Person2('图图',3,'红');