From cb996c0ba4e57686f27e5a813a5d519f495b4446 Mon Sep 17 00:00:00 2001 From: YangJ0605 <1442122744@qq.com> Date: Fri, 13 Dec 2019 10:39:40 +0800 Subject: [PATCH] note --- .DS_Store | Bin 0 -> 6148 bytes eventsloop/1206-2.html | 34 +++++ eventsloop/1206-class.html | 30 ++++ eventsloop/1206.html | 35 +++++ eventsloop/deepclone.html | 79 +++++++++++ eventsloop/event.html | 58 ++++++++ eventsloop/forin.html | 42 ++++++ eventsloop/promise.html | 92 ++++++++++++ eventsloop/task.html | 65 +++++++++ .../a1.js" | 2 + .../a2.js" | 4 + .../index.html" | 14 ++ .../index.js" | 4 + ...\345\205\270\351\235\242\350\257\225.html" | 41 ++++++ ...\216\257\346\211\223\345\215\2600-20.html" | 37 +++++ ...\347\233\256\346\240\207\345\200\274.html" | 43 ++++++ .../\345\233\236\346\226\207\346\225\260.js" | 29 ++++ .../1.txt" | 1 + .../2.txt" | 1 + .../promise,async.js" | 44 ++++++ ...\344\275\234\347\224\250\345\237\237.html" | 35 +++++ ...\344\270\212\344\270\213\346\226\207.html" | 58 ++++++++ .../\346\267\261\345\205\245this.html" | 35 +++++ ...\347\232\204\345\256\236\347\216\260.html" | 95 +++++++++++++ ...\347\232\204\345\256\236\347\216\260.html" | 134 ++++++++++++++++++ ...30\351\207\217\345\257\271\350\261\241.md" | 11 ++ ...21\351\232\276\346\235\202\347\227\207.js" | 45 ++++++ .../\351\227\255\345\214\205.js" | 13 ++ 28 files changed, 1081 insertions(+) create mode 100644 .DS_Store create mode 100644 eventsloop/1206-2.html create mode 100644 eventsloop/1206-class.html create mode 100644 eventsloop/1206.html create mode 100644 eventsloop/deepclone.html create mode 100644 eventsloop/event.html create mode 100644 eventsloop/forin.html create mode 100644 eventsloop/promise.html create mode 100644 eventsloop/task.html create mode 100644 "eventsloop/\346\250\241\345\235\227\345\214\226/a1.js" create mode 100644 "eventsloop/\346\250\241\345\235\227\345\214\226/a2.js" create mode 100644 "eventsloop/\346\250\241\345\235\227\345\214\226/index.html" create mode 100644 "eventsloop/\346\250\241\345\235\227\345\214\226/index.js" create mode 100644 "eventsloop/\347\273\217\345\205\270\351\235\242\350\257\225.html" create mode 100644 "leetcode and mianshi/\344\270\215\347\224\250\345\276\252\347\216\257\346\211\223\345\215\2600-20.html" create mode 100644 "leetcode and mianshi/\344\270\244\346\225\260\344\271\213\345\222\214\344\270\272\347\233\256\346\240\207\345\200\274.html" create mode 100644 "leetcode and mianshi/\345\233\236\346\226\207\346\225\260.js" create mode 100644 "\346\267\261\345\205\245\347\263\273\345\210\227/1.txt" create mode 100644 "\346\267\261\345\205\245\347\263\273\345\210\227/2.txt" create mode 100644 "\346\267\261\345\205\245\347\263\273\345\210\227/promise,async.js" create mode 100644 "\346\267\261\345\205\245\347\263\273\345\210\227/\344\275\234\347\224\250\345\237\237.html" create mode 100644 "\346\267\261\345\205\245\347\263\273\345\210\227/\346\211\247\350\241\214\344\270\212\344\270\213\346\226\207.html" create mode 100644 "\346\267\261\345\205\245\347\263\273\345\210\227/\346\267\261\345\205\245this.html" create mode 100644 "\346\267\261\345\205\245\347\263\273\345\210\227/\346\267\261\345\205\245\344\271\213apply\357\274\214call\347\232\204\345\256\236\347\216\260.html" create mode 100644 "\346\267\261\345\205\245\347\263\273\345\210\227/\346\267\261\345\205\245\344\271\213bind\347\232\204\345\256\236\347\216\260.html" create mode 100644 "\346\267\261\345\205\245\347\263\273\345\210\227/\346\267\261\345\205\245\345\217\230\351\207\217\345\257\271\350\261\241.md" create mode 100644 "\346\267\261\345\205\245\347\263\273\345\210\227/\347\226\221\351\232\276\346\235\202\347\227\207.js" create mode 100644 "\346\267\261\345\205\245\347\263\273\345\210\227/\351\227\255\345\214\205.js" diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..81932df753b1a1e1fd91d2a181fcf862450aa6af GIT binary patch literal 6148 zcmeHK!A`n531;JI^iT7nhcWD2n20@y2bb zzMFb!H)(jCE4(}N(w1-SbETq*?fDmB(7!FMAF4R@!Z_&Y$qk@h=M5GmbQk&YOP)^%iY@ks4R!|dZjFPYI~zmL2PVS4^HkL29Lw1(esO;n8UA8 z%bLY8yn-=vw>`HLM=HLDdCZ+1lcZ5PXa}cJ(i<;GNDL4I#K2rKU{6W0GM8^pFHH;( z13$?Co(~cf(Xp5r)JF#lx&;8tgIf#O*h^rJwCGsO48jZuH>rRomD?7Bn{@C?8|PTe z44QPtZS%qHlez6sxPCgUFLgNMjzJoU0b<}Q1K9h4l(7CEf8YP>AR34PV&H!=!1G7$ zQ3Lj7YwOf5vDQk^J5Usi%M4CZz|f@_VzCr&f@%T3L<7*Vm>C2Q2>lVzG|)f{{3-(< DDo9>H literal 0 HcmV?d00001 diff --git a/eventsloop/1206-2.html b/eventsloop/1206-2.html new file mode 100644 index 0000000..fbdf6b8 --- /dev/null +++ b/eventsloop/1206-2.html @@ -0,0 +1,34 @@ + + + + + + + Document + + + + + \ No newline at end of file diff --git a/eventsloop/1206-class.html b/eventsloop/1206-class.html new file mode 100644 index 0000000..cac6ad9 --- /dev/null +++ b/eventsloop/1206-class.html @@ -0,0 +1,30 @@ + + + + + + + Document + + + + + \ No newline at end of file diff --git a/eventsloop/1206.html b/eventsloop/1206.html new file mode 100644 index 0000000..c501079 --- /dev/null +++ b/eventsloop/1206.html @@ -0,0 +1,35 @@ + + + + + + + Document + + + + + + + + \ No newline at end of file diff --git a/eventsloop/deepclone.html b/eventsloop/deepclone.html new file mode 100644 index 0000000..efddb42 --- /dev/null +++ b/eventsloop/deepclone.html @@ -0,0 +1,79 @@ + + + + + + + 深拷贝的几种方式 + + + + + \ No newline at end of file diff --git a/eventsloop/event.html b/eventsloop/event.html new file mode 100644 index 0000000..aaa6b4a --- /dev/null +++ b/eventsloop/event.html @@ -0,0 +1,58 @@ + + + + + + + 事件 + + + +
+ +
+ + + + + \ No newline at end of file diff --git a/eventsloop/forin.html b/eventsloop/forin.html new file mode 100644 index 0000000..5e578c3 --- /dev/null +++ b/eventsloop/forin.html @@ -0,0 +1,42 @@ + + + + + + + Document + + + + + \ No newline at end of file diff --git a/eventsloop/promise.html b/eventsloop/promise.html new file mode 100644 index 0000000..a407f08 --- /dev/null +++ b/eventsloop/promise.html @@ -0,0 +1,92 @@ + + + + + + + promise + + + + + \ No newline at end of file diff --git a/eventsloop/task.html b/eventsloop/task.html new file mode 100644 index 0000000..8c8fc9b --- /dev/null +++ b/eventsloop/task.html @@ -0,0 +1,65 @@ + + + + + + + 宏任务与微任务 + + + + + \ No newline at end of file diff --git "a/eventsloop/\346\250\241\345\235\227\345\214\226/a1.js" "b/eventsloop/\346\250\241\345\235\227\345\214\226/a1.js" new file mode 100644 index 0000000..bc965e6 --- /dev/null +++ "b/eventsloop/\346\250\241\345\235\227\345\214\226/a1.js" @@ -0,0 +1,2 @@ +export var a1 = 1; +setTimeout(() => a1 = 2, 500) \ No newline at end of file diff --git "a/eventsloop/\346\250\241\345\235\227\345\214\226/a2.js" "b/eventsloop/\346\250\241\345\235\227\345\214\226/a2.js" new file mode 100644 index 0000000..2da1a3a --- /dev/null +++ "b/eventsloop/\346\250\241\345\235\227\345\214\226/a2.js" @@ -0,0 +1,4 @@ +var a2 = 2; +module.exports = a2; + +setTimeout(() => a2 = 3 ,500); \ No newline at end of file diff --git "a/eventsloop/\346\250\241\345\235\227\345\214\226/index.html" "b/eventsloop/\346\250\241\345\235\227\345\214\226/index.html" new file mode 100644 index 0000000..6ad6b05 --- /dev/null +++ "b/eventsloop/\346\250\241\345\235\227\345\214\226/index.html" @@ -0,0 +1,14 @@ + + + + + + + Document + + + + + \ No newline at end of file diff --git "a/eventsloop/\346\250\241\345\235\227\345\214\226/index.js" "b/eventsloop/\346\250\241\345\235\227\345\214\226/index.js" new file mode 100644 index 0000000..69c03e8 --- /dev/null +++ "b/eventsloop/\346\250\241\345\235\227\345\214\226/index.js" @@ -0,0 +1,4 @@ +import { a1 } from './a1.js'; +const a2 = require('./a2.js'); + +setTimeout(() => console.log(a1, a2), 1000) diff --git "a/eventsloop/\347\273\217\345\205\270\351\235\242\350\257\225.html" "b/eventsloop/\347\273\217\345\205\270\351\235\242\350\257\225.html" new file mode 100644 index 0000000..17474b5 --- /dev/null +++ "b/eventsloop/\347\273\217\345\205\270\351\235\242\350\257\225.html" @@ -0,0 +1,41 @@ + + + + + + + Document + + + + + \ No newline at end of file diff --git "a/leetcode and mianshi/\344\270\215\347\224\250\345\276\252\347\216\257\346\211\223\345\215\2600-20.html" "b/leetcode and mianshi/\344\270\215\347\224\250\345\276\252\347\216\257\346\211\223\345\215\2600-20.html" new file mode 100644 index 0000000..1283474 --- /dev/null +++ "b/leetcode and mianshi/\344\270\215\347\224\250\345\276\252\347\216\257\346\211\223\345\215\2600-20.html" @@ -0,0 +1,37 @@ + + + + + + + Document + + + + + \ No newline at end of file diff --git "a/leetcode and mianshi/\344\270\244\346\225\260\344\271\213\345\222\214\344\270\272\347\233\256\346\240\207\345\200\274.html" "b/leetcode and mianshi/\344\270\244\346\225\260\344\271\213\345\222\214\344\270\272\347\233\256\346\240\207\345\200\274.html" new file mode 100644 index 0000000..977a04a --- /dev/null +++ "b/leetcode and mianshi/\344\270\244\346\225\260\344\271\213\345\222\214\344\270\272\347\233\256\346\240\207\345\200\274.html" @@ -0,0 +1,43 @@ + + + + + + + Document + + + + + \ No newline at end of file diff --git "a/leetcode and mianshi/\345\233\236\346\226\207\346\225\260.js" "b/leetcode and mianshi/\345\233\236\346\226\207\346\225\260.js" new file mode 100644 index 0000000..ae91cc8 --- /dev/null +++ "b/leetcode and mianshi/\345\233\236\346\226\207\346\225\260.js" @@ -0,0 +1,29 @@ +/* +判断一个整数是否是回文数。回文数是指正序(从左向右)和倒序(从右向左)读都是一样的整数。 + +示例 1: + +输入: 121 +输出: true +*/ + +var sun = function(x) { + // if(x<0){ + // return false + // } + // if((x+'').split('').reverse().join('')==x){ + // return true + // }else { + // return false + // } + + let s =0 + let y = 0 + s=x + while(x>=1){ + y = x%10 + y*10 + x = Math.floor(x/10) + } + return y===s +} +sun(123) \ No newline at end of file diff --git "a/\346\267\261\345\205\245\347\263\273\345\210\227/1.txt" "b/\346\267\261\345\205\245\347\263\273\345\210\227/1.txt" new file mode 100644 index 0000000..e59afa6 --- /dev/null +++ "b/\346\267\261\345\205\245\347\263\273\345\210\227/1.txt" @@ -0,0 +1 @@ +我是第一个文件 \ No newline at end of file diff --git "a/\346\267\261\345\205\245\347\263\273\345\210\227/2.txt" "b/\346\267\261\345\205\245\347\263\273\345\210\227/2.txt" new file mode 100644 index 0000000..a1b1043 --- /dev/null +++ "b/\346\267\261\345\205\245\347\263\273\345\210\227/2.txt" @@ -0,0 +1 @@ +我是第二个文件 diff --git "a/\346\267\261\345\205\245\347\263\273\345\210\227/promise,async.js" "b/\346\267\261\345\205\245\347\263\273\345\210\227/promise,async.js" new file mode 100644 index 0000000..d2baa91 --- /dev/null +++ "b/\346\267\261\345\205\245\347\263\273\345\210\227/promise,async.js" @@ -0,0 +1,44 @@ +//promise.js + +const fs = require('fs') + +const read = function(fileName) { + return new Promise((a,b) => { + fs.readFile(fileName,(err,data) => { + if(err){ + b(err) + }else { + a(data) + } + }) + }) +} + +// console.log('promise') +// read('1.txt').then(res => { +// console.log(res.toString()) +// }).then((data) => { +// console.log(data) +// setTimeout(() => { +// return read('2.txt') +// }, 2000); // 会报错, +// }).then((res) => { +// console.log('22') +// console.log(res.toString()) +// }) + +console.log('async') + +async function readFileByasync(){ + try { + var a2 = await read('2.txt') + var a1 = await read('1.txt') + + }catch(e){ + console.log(e) + } + console.log(a1.toString()) + console.log(a2.toString()) +} + +readFileByasync() \ No newline at end of file diff --git "a/\346\267\261\345\205\245\347\263\273\345\210\227/\344\275\234\347\224\250\345\237\237.html" "b/\346\267\261\345\205\245\347\263\273\345\210\227/\344\275\234\347\224\250\345\237\237.html" new file mode 100644 index 0000000..9bbfb33 --- /dev/null +++ "b/\346\267\261\345\205\245\347\263\273\345\210\227/\344\275\234\347\224\250\345\237\237.html" @@ -0,0 +1,35 @@ + + + + + + + 静态作用域与动态作用域 + + +

JavaScript采用的是静态作用域,函数的作用域在定义的时候就决定了

+

相对的动态作用域,函数的作用域在函数调用的时候才决定

+ + + \ No newline at end of file diff --git "a/\346\267\261\345\205\245\347\263\273\345\210\227/\346\211\247\350\241\214\344\270\212\344\270\213\346\226\207.html" "b/\346\267\261\345\205\245\347\263\273\345\210\227/\346\211\247\350\241\214\344\270\212\344\270\213\346\226\207.html" new file mode 100644 index 0000000..d8dc834 --- /dev/null +++ "b/\346\267\261\345\205\245\347\263\273\345\210\227/\346\211\247\350\241\214\344\270\212\344\270\213\346\226\207.html" @@ -0,0 +1,58 @@ + + + + + + + + Document + + + + + + + \ No newline at end of file diff --git "a/\346\267\261\345\205\245\347\263\273\345\210\227/\346\267\261\345\205\245this.html" "b/\346\267\261\345\205\245\347\263\273\345\210\227/\346\267\261\345\205\245this.html" new file mode 100644 index 0000000..639eb23 --- /dev/null +++ "b/\346\267\261\345\205\245\347\263\273\345\210\227/\346\267\261\345\205\245this.html" @@ -0,0 +1,35 @@ + + + + + + + + 关于this + + + + + + + \ No newline at end of file diff --git "a/\346\267\261\345\205\245\347\263\273\345\210\227/\346\267\261\345\205\245\344\271\213apply\357\274\214call\347\232\204\345\256\236\347\216\260.html" "b/\346\267\261\345\205\245\347\263\273\345\210\227/\346\267\261\345\205\245\344\271\213apply\357\274\214call\347\232\204\345\256\236\347\216\260.html" new file mode 100644 index 0000000..c280996 --- /dev/null +++ "b/\346\267\261\345\205\245\347\263\273\345\210\227/\346\267\261\345\205\245\344\271\213apply\357\274\214call\347\232\204\345\256\236\347\216\260.html" @@ -0,0 +1,95 @@ + + + + + + + + call apply + + + + + + + + + \ No newline at end of file diff --git "a/\346\267\261\345\205\245\347\263\273\345\210\227/\346\267\261\345\205\245\344\271\213bind\347\232\204\345\256\236\347\216\260.html" "b/\346\267\261\345\205\245\347\263\273\345\210\227/\346\267\261\345\205\245\344\271\213bind\347\232\204\345\256\236\347\216\260.html" new file mode 100644 index 0000000..a6c9fab --- /dev/null +++ "b/\346\267\261\345\205\245\347\263\273\345\210\227/\346\267\261\345\205\245\344\271\213bind\347\232\204\345\256\236\347\216\260.html" @@ -0,0 +1,134 @@ + + + + + + + + bind + + + + + + + + + \ No newline at end of file diff --git "a/\346\267\261\345\205\245\347\263\273\345\210\227/\346\267\261\345\205\245\345\217\230\351\207\217\345\257\271\350\261\241.md" "b/\346\267\261\345\205\245\347\263\273\345\210\227/\346\267\261\345\205\245\345\217\230\351\207\217\345\257\271\350\261\241.md" new file mode 100644 index 0000000..8955ccf --- /dev/null +++ "b/\346\267\261\345\205\245\347\263\273\345\210\227/\346\267\261\345\205\245\345\217\230\351\207\217\345\257\271\350\261\241.md" @@ -0,0 +1,11 @@ + +### 对于每个执行上下文,都有三个重要属性: + - 变量对象(Variable object,VO) + - 作用域链(Scope chain) + - this + +### 变量对象 + +> 变量对象是与执行上下文相关的数据作用域,存储了在上下文中定义的变量和函数声明。 + +> 因为不同执行上下文下的变量对象稍有不同,所以我们来聊聊全局上下文下的变量对象和函数上下文下的变量对象。 diff --git "a/\346\267\261\345\205\245\347\263\273\345\210\227/\347\226\221\351\232\276\346\235\202\347\227\207.js" "b/\346\267\261\345\205\245\347\263\273\345\210\227/\347\226\221\351\232\276\346\235\202\347\227\207.js" new file mode 100644 index 0000000..e27df3d --- /dev/null +++ "b/\346\267\261\345\205\245\347\263\273\345\210\227/\347\226\221\351\232\276\346\235\202\347\227\207.js" @@ -0,0 +1,45 @@ +{ + let nAdd +let t = function () { + let n = 99 + nAdd = () => { + n++ + } + let t2 = function () { + console.log(n) + } + return t2 +} + +let a1 = t() +let a2 = t() + +nAdd() + +a1() +a2() + +//首先执行,a1 = t() 这是nadd赋值为 一个匿名函数 ,然后a2 = t() 这是nadd重新赋值了 所以后面nadd执行的是后面a2里面的重新赋值的那个nadd吧 所以a1 99 a2 100 + +} + +var t = function() { + var n = 99; + var t2 = function() { + n++ + console.log(n) + } + return t2; +}; + +var a1 = t(); +var a2 = t(); + +a1(); // 100 +a1(); // 101 + +a2(); // 100 +a2(); // 101 + +// 我们会发现,n 的值都是从 99 开始,执行 一次a1() 的时候,值会加一,再执行一次,值再加一,但是 n 在 a1() 和 a2() 并不是公用的。你可以理解为:同一个函数形成的多个闭包的值都是相互独立的。 + diff --git "a/\346\267\261\345\205\245\347\263\273\345\210\227/\351\227\255\345\214\205.js" "b/\346\267\261\345\205\245\347\263\273\345\210\227/\351\227\255\345\214\205.js" new file mode 100644 index 0000000..62616cd --- /dev/null +++ "b/\346\267\261\345\205\245\347\263\273\345\210\227/\351\227\255\345\214\205.js" @@ -0,0 +1,13 @@ +var data = [] + +for (var i = 0; i < 3; i++){ + data[i] = (function (i) { + return function(){ + console.log(i); + } + })(i) +} + +data[0]() +data[1]() +data[2]() \ No newline at end of file