From b6e28178f5097d8f3c1334a1428ce819d3b9ce57 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E6=B0=B8=E6=BD=98?= <1924969174@qq.com> Date: Thu, 3 Nov 2022 03:42:35 +0000 Subject: [PATCH 1/4] =?UTF-8?q?=E6=96=B0=E5=BB=BA=202022-10-28=E7=AC=AC?= =?UTF-8?q?=E4=B9=9D=E6=AC=A1=E9=A2=84=E7=BC=96=E8=AF=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../.keep" | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 "16\345\210\230\346\260\270\346\275\230/2022-10-28\347\254\254\344\271\235\346\254\241\351\242\204\347\274\226\350\257\221/.keep" diff --git "a/16\345\210\230\346\260\270\346\275\230/2022-10-28\347\254\254\344\271\235\346\254\241\351\242\204\347\274\226\350\257\221/.keep" "b/16\345\210\230\346\260\270\346\275\230/2022-10-28\347\254\254\344\271\235\346\254\241\351\242\204\347\274\226\350\257\221/.keep" new file mode 100644 index 0000000..e69de29 -- Gitee From fa44b4891ae3103be40c3d698c9edc8578e5cd53 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E6=B0=B8=E6=BD=98?= <1924969174@qq.com> Date: Thu, 3 Nov 2022 03:42:53 +0000 Subject: [PATCH 2/4] =?UTF-8?q?16=E5=88=98=E6=B0=B8=E6=BD=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 刘永潘 <1924969174@qq.com> --- ...60\351\242\204\347\274\226\350\257\221.md" | 47 +++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 "16\345\210\230\346\260\270\346\275\230/2022-10-28\347\254\254\344\271\235\346\254\241\351\242\204\347\274\226\350\257\221/2022-10-28\347\254\254\344\271\235\346\254\241\347\254\224\350\256\260\351\242\204\347\274\226\350\257\221.md" diff --git "a/16\345\210\230\346\260\270\346\275\230/2022-10-28\347\254\254\344\271\235\346\254\241\351\242\204\347\274\226\350\257\221/2022-10-28\347\254\254\344\271\235\346\254\241\347\254\224\350\256\260\351\242\204\347\274\226\350\257\221.md" "b/16\345\210\230\346\260\270\346\275\230/2022-10-28\347\254\254\344\271\235\346\254\241\351\242\204\347\274\226\350\257\221/2022-10-28\347\254\254\344\271\235\346\254\241\347\254\224\350\256\260\351\242\204\347\274\226\350\257\221.md" new file mode 100644 index 0000000..20855d3 --- /dev/null +++ "b/16\345\210\230\346\260\270\346\275\230/2022-10-28\347\254\254\344\271\235\346\254\241\351\242\204\347\274\226\350\257\221/2022-10-28\347\254\254\344\271\235\346\254\241\347\254\224\350\256\260\351\242\204\347\274\226\350\257\221.md" @@ -0,0 +1,47 @@ +作用域 + var:如果在全局,块级 --》 全局变量 局部作用域(function)-->局部变量 + let:不管在哪,都是局部 + 没有任何声明 a=5,不管在哪,都是全局 + + JS(单线程): + 扫描全局:看有没有语法错误 + 预编译(变量提升): +AO: + 1.创建一个AO(activation object)对象:临时存储容器 + 2.往AO装形参,值赋为undefined AO={a:undefined, b:undefined} + 2.1找变量声明,值也赋为undefined AO={a:undefined, b:undefined,c:undefined} + 3.将形参与实参的值统一 AO=AO={a:1, b:2,c:undefined} + 4.找函数声明,值赋予函数体AO={a:f a(){}, b:2,c:f c(){}} + 执行一句,解释一句 + 例: + function fn(a,b) { + console.log(a); // + function a(){} + var a = 5; + console.log(a); + console.log(c); // + var c = 3; + function c(){} + console.log(c); // + } + fn(1,2 + +GO: + 创建GO(Global Object)对象; + 寻找变量声明作为GO的属性名,并赋值为undefined; + 寻找函数声明,放入作为GO的属性,并赋值为其函数体。 + 谁先执行:GO={} AO={} + GO:文件执行之前 + AO:执行函数的前一刻 + GO={global:100, fn:f fn(){}} + global = 100; + //AO={global:300} + function fn() { + console.log(global); //undefined + global = 200; + console.log(global); //200 + var global = 300; + } + fn(); + console.log(global); //100 + var global; \ No newline at end of file -- Gitee From 0b1fa159d6d26262dd877c1b8282e6922134fd11 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E6=B0=B8=E6=BD=98?= <1924969174@qq.com> Date: Thu, 3 Nov 2022 03:43:12 +0000 Subject: [PATCH 3/4] =?UTF-8?q?=E6=96=B0=E5=BB=BA=202022-10-31=E7=AC=AC?= =?UTF-8?q?=E5=8D=81=E6=AC=A1=E9=97=AD=E5=8C=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../.keep" | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 "16\345\210\230\346\260\270\346\275\230/2022-10-31\347\254\254\345\215\201\346\254\241\351\227\255\345\214\205/.keep" diff --git "a/16\345\210\230\346\260\270\346\275\230/2022-10-31\347\254\254\345\215\201\346\254\241\351\227\255\345\214\205/.keep" "b/16\345\210\230\346\260\270\346\275\230/2022-10-31\347\254\254\345\215\201\346\254\241\351\227\255\345\214\205/.keep" new file mode 100644 index 0000000..e69de29 -- Gitee From 431c9155f6bd5b0655e78891f6c29932d04f7406 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E6=B0=B8=E6=BD=98?= <1924969174@qq.com> Date: Thu, 3 Nov 2022 03:43:22 +0000 Subject: [PATCH 4/4] =?UTF-8?q?16=E5=88=98=E6=B0=B8=E6=BD=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 刘永潘 <1924969174@qq.com> --- ...254\254\345\215\201\346\254\241\351\227\255\345\214\205.md" | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 "16\345\210\230\346\260\270\346\275\230/2022-10-31\347\254\254\345\215\201\346\254\241\351\227\255\345\214\205/2022-10-31\347\254\254\345\215\201\346\254\241\351\227\255\345\214\205.md" diff --git "a/16\345\210\230\346\260\270\346\275\230/2022-10-31\347\254\254\345\215\201\346\254\241\351\227\255\345\214\205/2022-10-31\347\254\254\345\215\201\346\254\241\351\227\255\345\214\205.md" "b/16\345\210\230\346\260\270\346\275\230/2022-10-31\347\254\254\345\215\201\346\254\241\351\227\255\345\214\205/2022-10-31\347\254\254\345\215\201\346\254\241\351\227\255\345\214\205.md" new file mode 100644 index 0000000..17c8ca7 --- /dev/null +++ "b/16\345\210\230\346\260\270\346\275\230/2022-10-31\347\254\254\345\215\201\346\254\241\351\227\255\345\214\205/2022-10-31\347\254\254\345\215\201\346\254\241\351\227\255\345\214\205.md" @@ -0,0 +1,3 @@ +作用域,作用域链 GO={a, outer} 最里面的先自动销毁 执行期上下文: 当函数执行前,会创建一个称为执行期上下文的内部对象(AO)。一个执行期上下文定义了一个函数执行时的环境, 函数每次执行时对应的执行上下文都是独一无二的,所以多次调用一个函数会导致创建多个执行上下文,当函数执行元毕, 它所产生的执行上下文被销毁。 查找变量:从作用域链的顶端依次向下查找。 function outer() { //oAO={a:undefined, inner:f inner(){}} function inner() { //iAO={b} var b = 23; console.log(a); } var a = 12; inner(); } var a = 100; outer(); + +闭包 闭包作用: 实现公有变量 可以做缓存(存储结构) 可以实现封装(继承) 模块化开发,防止污染全局变量, 闭包缺点:当函数保存在外部时,将会生成闭包,闭包会导致原有作用域链不释放,从而造成内存泄漏。 例: function a() { var aa = '这是外层函数'; // console.log(aa); function b() { // var bb = '这是中层函数'; console.log(aa); } return b; } //a(); // console.log(aa); var fun = a(); fun(); \ No newline at end of file -- Gitee