From af134c97af351a2e746cd542aae8bab15fada257 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=83=91=E5=AE=97=E5=B8=85?= <10033721+TXYforever@user.noreply.gitee.com> Date: Sun, 6 Nov 2022 11:00:15 +0000 Subject: [PATCH 1/3] =?UTF-8?q?14=20=E9=83=91=E5=AE=97=E5=B8=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 郑宗帅 <> --- .../2022.10.28\347\254\224\350\256\260.md" | 20 +++++++++++++++++++ .../\347\254\224\350\256\260/2022.10.30.md" | 18 +++++++++++++++++ 2 files changed, 38 insertions(+) create mode 100644 "14\351\203\221\345\256\227\345\270\205/\347\254\224\350\256\260/2022.10.28\347\254\224\350\256\260.md" create mode 100644 "14\351\203\221\345\256\227\345\270\205/\347\254\224\350\256\260/2022.10.30.md" diff --git "a/14\351\203\221\345\256\227\345\270\205/\347\254\224\350\256\260/2022.10.28\347\254\224\350\256\260.md" "b/14\351\203\221\345\256\227\345\270\205/\347\254\224\350\256\260/2022.10.28\347\254\224\350\256\260.md" new file mode 100644 index 0000000..ed2f92d --- /dev/null +++ "b/14\351\203\221\345\256\227\345\270\205/\347\254\224\350\256\260/2022.10.28\347\254\224\350\256\260.md" @@ -0,0 +1,20 @@ +8、预编译 +预编译(变量提升) + +AO(Activation Object)在函数执行前创建 + +创建一个AO临时对象 + +找形参,装入AO,赋值为underfined。找变量声明,装入AO,赋值为underfined + +形参与实参统一 + +找函数声明,赋予函数体 + +GO(Clobal Object)在文件执行前创建 + +创建一个GO临时对象 + +找形参,装入AO,赋值为underfined。找变量声明,装入AO,赋值为underfined + +找函数声明,赋予函数体 \ No newline at end of file diff --git "a/14\351\203\221\345\256\227\345\270\205/\347\254\224\350\256\260/2022.10.30.md" "b/14\351\203\221\345\256\227\345\270\205/\347\254\224\350\256\260/2022.10.30.md" new file mode 100644 index 0000000..680ef55 --- /dev/null +++ "b/14\351\203\221\345\256\227\345\270\205/\347\254\224\350\256\260/2022.10.30.md" @@ -0,0 +1,18 @@ +9、闭包 +var add = (function () { + var counter = 0; + return function () { + return counter += 1; + } +})(); + +add(); +add(); +add(); + +// 计数器目前是 3 +个闭包由两部分组成,函数和创建该函数的环境。 + +由于闭包会携带包含它的函数的作用域,因此会比其他函数占用更多的内存。 + +闭包缺点:当函数保存在外部时,将会生成闭包,闭包会导致原有作用域链不释放,从而造成内存泄漏 \ No newline at end of file -- Gitee From 49bf44a9d2dc5faeb41dae21cb82348fef14bf92 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=83=91=E5=AE=97=E5=B8=85?= <10033721+TXYforever@user.noreply.gitee.com> Date: Sun, 6 Nov 2022 11:07:35 +0000 Subject: [PATCH 2/3] =?UTF-8?q?14=20=E9=83=91=E5=AE=97=E5=B8=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 郑宗帅 <> --- .../\344\275\234\344\270\232/2022.11.3.html" | 44 ++++++++++ .../2022.11.4\344\275\234\344\270\232.html" | 83 +++++++++++++++++++ 2 files changed, 127 insertions(+) create mode 100644 "14\351\203\221\345\256\227\345\270\205/\344\275\234\344\270\232/2022.11.3.html" create mode 100644 "14\351\203\221\345\256\227\345\270\205/\344\275\234\344\270\232/2022.11.4\344\275\234\344\270\232.html" diff --git "a/14\351\203\221\345\256\227\345\270\205/\344\275\234\344\270\232/2022.11.3.html" "b/14\351\203\221\345\256\227\345\270\205/\344\275\234\344\270\232/2022.11.3.html" new file mode 100644 index 0000000..3c25b15 --- /dev/null +++ "b/14\351\203\221\345\256\227\345\270\205/\344\275\234\344\270\232/2022.11.3.html" @@ -0,0 +1,44 @@ + + + + + + + Document + + + + + \ No newline at end of file diff --git "a/14\351\203\221\345\256\227\345\270\205/\344\275\234\344\270\232/2022.11.4\344\275\234\344\270\232.html" "b/14\351\203\221\345\256\227\345\270\205/\344\275\234\344\270\232/2022.11.4\344\275\234\344\270\232.html" new file mode 100644 index 0000000..958f450 --- /dev/null +++ "b/14\351\203\221\345\256\227\345\270\205/\344\275\234\344\270\232/2022.11.4\344\275\234\344\270\232.html" @@ -0,0 +1,83 @@ + + + + + + + Document + + + + + \ No newline at end of file -- Gitee From 682537b1c58e021783f1f9f91134b80c2e4b449c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=83=91=E5=AE=97=E5=B8=85?= <10033721+TXYforever@user.noreply.gitee.com> Date: Sun, 6 Nov 2022 11:08:05 +0000 Subject: [PATCH 3/3] =?UTF-8?q?14=20=E9=83=91=E5=AE=97=E5=B8=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 郑宗帅 <> --- .../2022.11.3\347\254\224\350\256\260.md" | 69 +++++++++ .../2022.11.4\347\254\224\350\256\260.md" | 132 ++++++++++++++++++ 2 files changed, 201 insertions(+) create mode 100644 "14\351\203\221\345\256\227\345\270\205/\347\254\224\350\256\260/2022.11.3\347\254\224\350\256\260.md" create mode 100644 "14\351\203\221\345\256\227\345\270\205/\347\254\224\350\256\260/2022.11.4\347\254\224\350\256\260.md" diff --git "a/14\351\203\221\345\256\227\345\270\205/\347\254\224\350\256\260/2022.11.3\347\254\224\350\256\260.md" "b/14\351\203\221\345\256\227\345\270\205/\347\254\224\350\256\260/2022.11.3\347\254\224\350\256\260.md" new file mode 100644 index 0000000..573624c --- /dev/null +++ "b/14\351\203\221\345\256\227\345\270\205/\347\254\224\350\256\260/2022.11.3\347\254\224\350\256\260.md" @@ -0,0 +1,69 @@ +函数 +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 diff --git "a/14\351\203\221\345\256\227\345\270\205/\347\254\224\350\256\260/2022.11.4\347\254\224\350\256\260.md" "b/14\351\203\221\345\256\227\345\270\205/\347\254\224\350\256\260/2022.11.4\347\254\224\350\256\260.md" new file mode 100644 index 0000000..fdc1359 --- /dev/null +++ "b/14\351\203\221\345\256\227\345\270\205/\347\254\224\350\256\260/2022.11.4\347\254\224\350\256\260.md" @@ -0,0 +1,132 @@ +//构造函数的属性优先于原型上的属性 + // function Fun(){ + // // this.name = '陈鹏' + // } + // Fun.prototype.name = '1' + // //实例化 + // var fun = new Fun(); + + // Fun.prototype.name = '3' + + + // //原型重写 + // Fun.prototype = {}; + // Fun.prototype.name = '2' + // var fun1 = new Fun(); + + // console.log(fun.name); // + // console.log(fun1.name); + + + //原型链 继承:继承父类的属性和方法 + + //原型链继承:会将父级上的所有属性和方法统统继承过来:过多地继承没用的属性 + // function Grand() {} //爷爷 + // function Parent() {} //爸爸 + // // function Child() {} //孩子 + // Grand.prototype.tskill = '拉二胡'; + // // Grand.prototype.hskill = '弹琴'; + // // Grand.prototype.Intro = () => { console.log('I am grandpa');} + // // //Parent.prototype.mskill = '吃饭' //失效 + // // //原型重写 + + // var grand = new Grand(); + + // Parent.prototype = grand; + + // var parent = new Parent(); + // Parent.prototype.tskill = '弹琴'; + + // // //添加属性,必须在重写之后 + // // Parent.prototype.mskill = '做饭'; + + + // console.log(parent.tskill); + // console.log(grand.tskill); + // console.log(parent.mskill); + + // Child.prototype.lskill = '学习'; + // Child.prototype = parent; + // Child.prototype.lskill = '睡觉'; + + // var child = new Child(); + // console.log(child.lskill); + + + //2.构造函数继承:使用call + // function Parent(name,age){ + // this.name = name; //child.name + // this.age = age; //child.age + // } + + // function Child(name,age,sex){ + // //call + // Parent.call(this,name,age); + // this.sex = sex; + // } + // var child = new Child('张三',18,'male'); + // console.log(child.name); + + //3.共享原型继承 + // function Grand(){} + // Grand.prototype.name = '爷爷'; + + // function Parent(){ + // } + // Parent.prototype.name = '爹'; + // Parent.prototype.age = 40; + + // function Child(){ + // } + + // function inherit(Target,Origin){ + // Target.prototype = Origin.prototype; + // } + + // inherit(Child,Parent); + // Child.prototype.age = 100; //共享 + // // Parent.prototype.age = 18; + // var child = new Child(); + // console.log(child.name); + // console.log(child.age); + // var parent = new Parent(); + // console.log(parent.age); + + + //4.圣杯(永恒)模式 + function Parent() { + } + Parent.prototype.name = '爹'; + Parent.prototype.age = 40; + + function Child() { + } + + function inherit(Target, Origin) { + function F(){} //临时构造函数 + F.prototype = Origin.prototype; + // var f = new F();//实例化:复制一份 + // Target.prototype = f; //独立的f,里面有父类所有的属性和方法 + Target.prototype = new F(); + //归位 + //构造器归位 + Target.prototype.constructor = Target; + //超类 + Target.prototype.uber = Origin; + + } + + //Parent.prototype.constructor + + + inherit(Child, Parent); + var child = new Child(); + console.log(child.__proto__.uber); + // child.__proto__.name = '张三'; + // Child.prototype.name = '张三'; + // console.log(child.name); + // console.log(Child.prototype.constructor); + + // var parent = new Parent(); + // console.log(); + // console.log(parent.name); \ No newline at end of file -- Gitee