From 31474b89572d92c508be1fe9483709047b946493 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=BD=97=E6=AD=A4=E4=B8=9C?= <3352403143@qq.com> Date: Thu, 3 Nov 2022 03:46:13 +0000 Subject: [PATCH 1/6] =?UTF-8?q?=E6=96=B0=E5=BB=BA=202022.11.2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- "33\347\275\227\346\255\244\344\270\234/2022.11.2/.keep" | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 "33\347\275\227\346\255\244\344\270\234/2022.11.2/.keep" diff --git "a/33\347\275\227\346\255\244\344\270\234/2022.11.2/.keep" "b/33\347\275\227\346\255\244\344\270\234/2022.11.2/.keep" new file mode 100644 index 0000000..e69de29 -- Gitee From 91ffd7d2cf8560bbf5fdacde98ee72d30e059d66 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=BD=97=E6=AD=A4=E4=B8=9C?= <3352403143@qq.com> Date: Thu, 3 Nov 2022 03:47:01 +0000 Subject: [PATCH 2/6] =?UTF-8?q?=E4=BD=9C=E4=B8=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 罗此东 <3352403143@qq.com> --- .../2022.11.2/2022_11_02.html" | 35 ++++++++ .../2022.11.2/\345\207\275\346\225\260.md" | 81 +++++++++++++++++++ 2 files changed, 116 insertions(+) create mode 100644 "33\347\275\227\346\255\244\344\270\234/2022.11.2/2022_11_02.html" create mode 100644 "33\347\275\227\346\255\244\344\270\234/2022.11.2/\345\207\275\346\225\260.md" diff --git "a/33\347\275\227\346\255\244\344\270\234/2022.11.2/2022_11_02.html" "b/33\347\275\227\346\255\244\344\270\234/2022.11.2/2022_11_02.html" new file mode 100644 index 0000000..a6cd186 --- /dev/null +++ "b/33\347\275\227\346\255\244\344\270\234/2022.11.2/2022_11_02.html" @@ -0,0 +1,35 @@ + + + + + + + Document + + + + + \ No newline at end of file diff --git "a/33\347\275\227\346\255\244\344\270\234/2022.11.2/\345\207\275\346\225\260.md" "b/33\347\275\227\346\255\244\344\270\234/2022.11.2/\345\207\275\346\225\260.md" new file mode 100644 index 0000000..f8801ef --- /dev/null +++ "b/33\347\275\227\346\255\244\344\270\234/2022.11.2/\345\207\275\346\225\260.md" @@ -0,0 +1,81 @@ +# 函数 + +###### call,apply,bind + +改变this指向,函数被执行时,内部会产生一个this + +arguments:伪数组,只有下标,长度,元素是实参的映射 + +实列:(call apply 两者类似) + +``` +function Person(name, age) { + + var { name : '张三' ,age:18} + + console.log(this); + + this.name = name; //obj.name = name; + + this.age = age; //obj.age = age; + + return {} + + } + + var obj = {}; + +Person.call(obj,'张三',18); +Person.apply(obj, ['张三', 18]); +Person('张三',18); +``` + +实列:bind + +``` + // const module = { + // x: 42, + // getX: function () { + // console.log(this); + // return this.x; //window.x + // } + // }; + + // var x = 99; + //bind + // const unboundGetX = module.getX; + // console.log(unboundGetX()); //42 + // const boundGetX = unboundGetX.bind(module);//函数 调用bind方法,返回一个带this指向的新函数 + // console.log(boundGetX()); +``` + +#### 严格模式('use strict') + +:严格模式:防止意外发生错误时,及时抛出该错误 + +1.在严格模式下,函数内部不会再意外地生成全局变量,而是抛出异常 + +2.严格模式要求一个对象内的所有属性名在对象内必须唯一 + +3.严格模式下会抛出错误,非严格模式会自动转换全局 + +4.构造函数使用严格模式,必须使用new: + +``` + // function Product(name, price) { + // 'use strict' + // this.name = name; + // this.price = price; + // } + // new Product('张三',18); +``` + +函数命名 + + //构造函数:Person() + +​ //普通函数小驼峰: getNameAge + +​ //普通变量: personAge perons_age + +​ //常量:PI \ No newline at end of file -- Gitee From c2c73d73325d80a12addf0dc2b1d69653b900beb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=BD=97=E6=AD=A4=E4=B8=9C?= <3352403143@qq.com> Date: Fri, 4 Nov 2022 10:33:20 +0800 Subject: [PATCH 3/6] =?UTF-8?q?=E4=BD=9C=E4=B8=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../2022.11.3/202211.3.html" | 38 +++++++++ .../2022.11.3/\345\216\237\345\236\213.md" | 80 +++++++++++++++++++ 2 files changed, 118 insertions(+) create mode 100644 "33\347\275\227\346\255\244\344\270\234/2022.11.3/202211.3.html" create mode 100644 "33\347\275\227\346\255\244\344\270\234/2022.11.3/\345\216\237\345\236\213.md" diff --git "a/33\347\275\227\346\255\244\344\270\234/2022.11.3/202211.3.html" "b/33\347\275\227\346\255\244\344\270\234/2022.11.3/202211.3.html" new file mode 100644 index 0000000..a0d9dd7 --- /dev/null +++ "b/33\347\275\227\346\255\244\344\270\234/2022.11.3/202211.3.html" @@ -0,0 +1,38 @@ + + + + + + + Document + + + + + \ No newline at end of file diff --git "a/33\347\275\227\346\255\244\344\270\234/2022.11.3/\345\216\237\345\236\213.md" "b/33\347\275\227\346\255\244\344\270\234/2022.11.3/\345\216\237\345\236\213.md" new file mode 100644 index 0000000..be86e0a --- /dev/null +++ "b/33\347\275\227\346\255\244\344\270\234/2022.11.3/\345\216\237\345\236\213.md" @@ -0,0 +1,80 @@ +# 原型 + +prototype : 原型 + +constructor : 构造器 + +实列: + +``` +function Computer(brand,os) { + this.brand = brand; + this.os = os; + } + var computer1 = new Computer('Lenovo','Intel 5'); + var computer2 = new Computer('Mac','M2'); + Computer.prototype.screen = '18:9'; +console.log(function.prototype) +``` + +其中原型本身也是对象!!! + +另外所有的对象都有原型,包括prototype本身 + +其中 原型有原型:Object --> null + +##### 增删改: + +改: + +``` + Computer.prototype.screen = '18:9'; +``` + +``` +Computer.prototype.screen = '20:10'; +``` + +删: + +``` +delete Phone.prototype.screen; +``` + +构造函数的原型是可以修改的 + +constructor构造器也可以修改 + +##### 原型的重写: + +``` +function Fun1(){} + var fun = function () { } + 原型的重写 + fun.prototype = { + //可以手动添加构造器 + // constructor:fun, + name: 'peter', + age: 25 + } + // fun.prototype.sex = '男'; + var a = new fun(); //重写时数据写在new之前 + // fun.prototype.title = '学生'; + // console.log(a.__proto__); //fun + var b = new fun(); + console.log(a.name, b.name); //peter.peter + fun.prototype.name = 'jack'; + console.log(a.name, b.name); //jack jack + //重写原型 + fun.prototype = {}; + fun.prototype.name = 'tom'; + console.log(a.name, b.name); //jack jack + //b.constructor + b.constructor.prototype.name = 'kitty'; + //b.__proto__name = 'tom' 修改原型上的属性,相当于修改a,b + //b.name = 'tom' 修改b的 + console.log(a.name, b.name); //jack jack + +``` + +重写时数据写在new之前!!! \ No newline at end of file -- Gitee From ad8f115e6e61f66a59745463ee7d1709c1a520a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=BD=97=E6=AD=A4=E4=B8=9C?= <3352403143@qq.com> Date: Mon, 7 Nov 2022 09:48:07 +0800 Subject: [PATCH 4/6] zuoye --- .../2022.11.4/2022-11-4.html" | 84 +++++++++++ ...76\345\222\214\347\273\247\346\211\277.md" | 132 ++++++++++++++++++ 2 files changed, 216 insertions(+) create mode 100644 "33\347\275\227\346\255\244\344\270\234/2022.11.4/2022-11-4.html" create mode 100644 "33\347\275\227\346\255\244\344\270\234/2022.11.4/\345\216\237\345\236\213\351\223\276\345\222\214\347\273\247\346\211\277.md" diff --git "a/33\347\275\227\346\255\244\344\270\234/2022.11.4/2022-11-4.html" "b/33\347\275\227\346\255\244\344\270\234/2022.11.4/2022-11-4.html" new file mode 100644 index 0000000..50ac8e7 --- /dev/null +++ "b/33\347\275\227\346\255\244\344\270\234/2022.11.4/2022-11-4.html" @@ -0,0 +1,84 @@ + + + + + + + Document + + + + + \ No newline at end of file diff --git "a/33\347\275\227\346\255\244\344\270\234/2022.11.4/\345\216\237\345\236\213\351\223\276\345\222\214\347\273\247\346\211\277.md" "b/33\347\275\227\346\255\244\344\270\234/2022.11.4/\345\216\237\345\236\213\351\223\276\345\222\214\347\273\247\346\211\277.md" new file mode 100644 index 0000000..09fc20d --- /dev/null +++ "b/33\347\275\227\346\255\244\344\270\234/2022.11.4/\345\216\237\345\236\213\351\223\276\345\222\214\347\273\247\346\211\277.md" @@ -0,0 +1,132 @@ +# 原型链和继承 + +原型链继承:会将父级上的所有属性和方法统统继承过来(过多地继承没用的属性) + +添加属性必须在重写之后否则不会生效 + +###### 原型链继承 + +原型链 继承:继承父类的属性和方法 + +原型链继承:会将父级上的所有属性和方法统统继承过来:过多地继承没用的属性 + +列如: + +``` +function Grand(){} +function Parent(){} +Grand.prototype.tskill = '拉二胡'; +var grand = new Grand(); +Parent.prototype = grand; +var parent = new Parent(); +Parent.prototype.tskill = '弹琴'; +其中如果要添加属性,需要在重写之后 +``` + + + +###### 构造函数继承 + +例子: + + `function Parent(name,age){` + + `this.name = name;` + + `this.age = age; ` + + `}` + + + + `function Child(name,age,sex){` + + `Parent.call(this,name,age);` + + `this.sex = sex;` + + `}` + +构造函数的属性优先于原型上的属性 + + + +###### 共享原型继承 + +子级上的修改会影响所处同一原型链上的所有对象 + +例子: + + `function Parent(){` + + `}` + + `Parent.prototype.name = '爹';` + + `Parent.prototype.age = 40;` + + `function Child(){` + + `}` + +Target:指向的构造函数 + +Origin:源头的构造函数 + + `function inherit(Target,Origin){` + + `Target.prototype = Origin.prototype;` + + `}` + + inherit(Child,Parent) + + + +###### 圣杯模式 + +例子: + + `function Parent(){` + + `}` + + `Parent.prototype.name = '爹';` + + `Parent.prototype.age = 40;` + + `function Child(){` + + `}` + + `function inherit(Target, Origin) {` + + `function F(){} `//临时构建函数 + + + + `F.prototype = Origin.prototype;` + + + + `Target.prototype = new F();` + + + + ``Target.prototype.constructor = Target;` + + + + + + `Target.prototype.uber = Origin;` + + + + `}` + + inherit(Child, Parent); + + + +这种圣杯模式的本质在于,中间生成了一个对象(构造函数),起到了隔离的作用,今后为child.prototype添加属性时,全部都会加在这个对象里面,所以不会对父级产生影响。而向上查找是沿着_ proto_查找,可以顺利查找到父级的属性,实现继承。 \ No newline at end of file -- Gitee From 22a22eca908cfef754c3944295cf017de2be05c8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=BD=97=E6=AD=A4=E4=B8=9C?= <3352403143@qq.com> Date: Mon, 14 Nov 2022 04:45:07 +0000 Subject: [PATCH 5/6] =?UTF-8?q?=E6=96=B0=E5=BB=BA=202022.11.7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- "33\347\275\227\346\255\244\344\270\234/2022.11.7/.keep" | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 "33\347\275\227\346\255\244\344\270\234/2022.11.7/.keep" diff --git "a/33\347\275\227\346\255\244\344\270\234/2022.11.7/.keep" "b/33\347\275\227\346\255\244\344\270\234/2022.11.7/.keep" new file mode 100644 index 0000000..e69de29 -- Gitee From 038bb4573b836cd89ca8eb6cf0f851ee0cf666e6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=BD=97=E6=AD=A4=E4=B8=9C?= <3352403143@qq.com> Date: Mon, 14 Nov 2022 04:45:46 +0000 Subject: [PATCH 6/6] =?UTF-8?q?=E4=BD=9C=E4=B8=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 罗此东 <3352403143@qq.com> --- .../2022.11.7/2022_11_7.html" | 24 ++++++++ .../\347\273\247\346\211\277\344\270\213.md" | 61 +++++++++++++++++++ 2 files changed, 85 insertions(+) create mode 100644 "33\347\275\227\346\255\244\344\270\234/2022.11.7/2022_11_7.html" create mode 100644 "33\347\275\227\346\255\244\344\270\234/2022.11.7/\347\273\247\346\211\277\344\270\213.md" diff --git "a/33\347\275\227\346\255\244\344\270\234/2022.11.7/2022_11_7.html" "b/33\347\275\227\346\255\244\344\270\234/2022.11.7/2022_11_7.html" new file mode 100644 index 0000000..f3a5b45 --- /dev/null +++ "b/33\347\275\227\346\255\244\344\270\234/2022.11.7/2022_11_7.html" @@ -0,0 +1,24 @@ + + + + + + + Document + + + + + \ No newline at end of file diff --git "a/33\347\275\227\346\255\244\344\270\234/2022.11.7/\347\273\247\346\211\277\344\270\213.md" "b/33\347\275\227\346\255\244\344\270\234/2022.11.7/\347\273\247\346\211\277\344\270\213.md" new file mode 100644 index 0000000..a623b19 --- /dev/null +++ "b/33\347\275\227\346\255\244\344\270\234/2022.11.7/\347\273\247\346\211\277\344\270\213.md" @@ -0,0 +1,61 @@ +### 继承下 + +###### 圣杯模式最终版 + +实例: + +``` +function Parent() {} +function Child() {} +Parent.prototype.name = 'cp'; + + var inherit = (function() { + function Temp(){};//闭包实现实例化 + return function (Target , Origin){ + temp.prototype = new Temp(); + //归位 + Target.prototype.constructor=Target; + //超类 + Target.prototype.uber=Origin; +}()} +inherit(Child,Parent); +console.log(Child.prototype.uber); + + + +``` + +###### ES6: + + class继承(语法糖):基于原型链的继承 + +``` + class Parent{ + constructor(name,age){ + this.name = name; + this.age = age; + } + eating(){ + console.log('吃饭了'); + } + } + //sex,name,age + //使用extends + class Child extends Parent{ + constructor(sex){ + super(name,age);//即使父类没有参数,也不能省略super//调用父类的constructor + this.sex=sex; + } + running(){ + console.log('paobu'); + } + } + var child = new Child('male','cp',18); +``` + +###### for...in() & for...of 的区别 + +for ... in()不管是不是可迭代 都能迭代出来(键值对=>键/数组=>下标) + +for ... of 如果不可迭代则无效 + -- Gitee