zheng 1 dienu atpakaļ
vecāks
revīzija
932e9ba6a7
4 mainītis faili ar 120 papildinājumiem un 0 dzēšanām
  1. 6 0
      12.正则/1.正则.html
  2. 44 0
      15.ts/4.面向对象/src/6.泛型.ts
  3. 32 0
      继承/1.html
  4. 38 0
      继承/2.html

+ 6 - 0
12.正则/1.正则.html

@@ -37,6 +37,12 @@
          * for in / for of
          * map/forEach
          * 为什么data是函数
+         * 
+         * this指向
+         * call bind apply
+         * Promise
+         * async await
+         * eventLoop
          */
         let arr = [1, 2, 3, 4, 5];
         let obj = {

+ 44 - 0
15.ts/4.面向对象/src/6.泛型.ts

@@ -0,0 +1,44 @@
+(function () {
+    // 泛型:用字符去指代未知类型
+    function fn1<T>(xx: T): T {
+        return xx;
+    }
+    fn1(12);
+    fn1('12');
+    fn1<boolean>(true);
+
+    function fn2<T, K>(x: T, y: K): [T, K] {
+        return [x, y];
+    }
+    fn2(12, '10')
+
+    interface happy {
+        weather: string
+    }
+
+    function fn3<T extends happy>(a: T): T {
+        return a;
+    }
+    fn3({ weather: "晴天" })
+
+
+    class Person<T extends happy> {
+        name: T
+        constructor(name: T) {
+            this.name = name;
+        }
+    }
+    let p = new Person({ weather: "晴天" })
+    // interface a {}
+})()
+
+/**
+ * 1.interface 和 type区别
+ * 2.联合类型 和 交叉类型
+ * 3.泛型是什么 有什么作用
+ * 4.类型断言
+ * 5.any never unknown区别
+ * 6.ts类型有什么
+ * 7.数组和元祖的区别
+ * 8.class和interface的区别
+ */

+ 32 - 0
继承/1.html

@@ -0,0 +1,32 @@
+<!DOCTYPE html>
+<html lang="en">
+
+<head>
+    <meta charset="UTF-8">
+    <meta name="viewport" content="width=device-width, initial-scale=1.0">
+    <title>原型链继承</title>
+</head>
+
+<body>
+    <script>
+        function Father() {
+            this.name = 'Lucy';
+            this.arr = [1, 2, 3];
+        }
+
+        function Child() {
+            this.age = 10;
+        }
+
+        Child.prototype = new Father();
+        const c1 = new Child();
+        const c2 = new Child();
+        c1.age = 18;
+        c1.name = '图图'
+        c1.arr.push('00')
+        console.log(c1, 'c1')
+        console.log(c2, 'c2')
+    </script>
+</body>
+
+</html>

+ 38 - 0
继承/2.html

@@ -0,0 +1,38 @@
+<!DOCTYPE html>
+<html lang="en">
+
+<head>
+    <meta charset="UTF-8">
+    <meta name="viewport" content="width=device-width, initial-scale=1.0">
+    <title>构造函数继承</title>
+</head>
+
+<body>
+    <script>
+        function Father() {
+            this.name = 'Lucy';
+            this.arr = [1, 2, 3];
+            this.fn1 = function () {
+                console.log("哈哈哈")
+            }
+        }
+        Father.prototype.say = function () {
+            console.log("你好")
+        }
+
+        function Child() {
+            this.age = 10;
+            Father.apply(this)
+            // Father.call(this)
+        }
+        const c1 = new Child();
+        const c2 = new Child();
+        c1.arr.push('00')
+        console.log(c1, 'c1');
+        console.log(c2, 'c2')
+        // c2.say()
+        c1.fn1()
+    </script>
+</body>
+
+</html>