diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..225e8e5 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,3 @@ +{ + "typescript.validate.enable": false +} \ No newline at end of file diff --git a/CSSdemo/heart.html b/CSSdemo/heart.html new file mode 100644 index 0000000..e5753cd --- /dev/null +++ b/CSSdemo/heart.html @@ -0,0 +1,114 @@ + + + + + + + 跳动的小爱心 + + +
+
+ + + + \ No newline at end of file diff --git a/ES6/defineProperty.js b/ES6/defineProperty.js new file mode 100644 index 0000000..0f4f660 --- /dev/null +++ b/ES6/defineProperty.js @@ -0,0 +1,62 @@ +// 属性描述符必须是数据描述符或者存取描述符两种形式之一,不能同时是两者 + +Object.defineProperty({}, "num", { + value: 1, + writable: true, + enumerable: true, + configurable: true +}); + + +var value = 1; +Object.defineProperty({}, "num", { + get : function(){ + return value; + }, + set : function(newValue){ + value = newValue; + }, + enumerable : true, + configurable : true +}); + + +// Object.defineProperty({}, "num", { +// value: 1, +// get: function() { +// return 1; +// } +// }); 报错 + +function Test() { + var name = null + var names = [] + + Object.defineProperty(this,'name', { + get(){ + console.log('get操作') + return name + }, + set(newValue){ + console.log('set操作') + name = newValue + names.push({name: name}) + } + }) + this.getName = function(){ + return names + } +} + +var tt = new Test() + +tt.name +tt.name = 'yy' +tt.name = 'zz' +tt.getName() + + +var obj = { + value: 1 +} + diff --git a/ES6/proxy.js b/ES6/proxy.js new file mode 100644 index 0000000..b402ec4 --- /dev/null +++ b/ES6/proxy.js @@ -0,0 +1,7 @@ +// @ts-nocheck +var proxy = new Proxy({}, { + get(target, propKey){ + return 35 + } +}) + diff --git a/ES6/watch.html b/ES6/watch.html new file mode 100644 index 0000000..2ee6a38 --- /dev/null +++ b/ES6/watch.html @@ -0,0 +1,52 @@ + + + + + + + + Document + + + + 1 + + + + + + \ No newline at end of file diff --git a/every morning/1217.js b/every morning/1217.js new file mode 100644 index 0000000..4a3f20f --- /dev/null +++ b/every morning/1217.js @@ -0,0 +1,17 @@ +function a() { + console.log(1) +} +(function f(b){ + a() + a = function() { + console.log(2) + } + function a(){ + console.log(3) + } + a() + var a + a && a() + b() +})(a) +//3 2 2 1 \ No newline at end of file diff --git a/every morning/1218.js b/every morning/1218.js new file mode 100644 index 0000000..51f3be8 --- /dev/null +++ b/every morning/1218.js @@ -0,0 +1,77 @@ +// js 赋值语句有返回值,就是等号右边的值! + +function foo() { + console.log( this.a ); +} + +var a = 2; +var o = { a: 3, foo: foo }; +var p = { a: 4 }; + +o.foo(); //3 +(p.foo = o.foo)(); //2 + +function xx() { + console.log(this.name) +} + +var obj = { + name: 'obj', + yy(){ + console.log(this) + } +} +var obj2 = { + name: 'obj2' +} + +obj.yy(); + +(obj2.zz = obj.yy)(); + + +//逗号运算符,它将先计算左边的参数,再计算右边的参数值。然后返回最右边参数的值。 + +var a = 10, b = 20; + +function CommaTest(){ + return a++, b++, 10; +} + +var c = CommaTest(); + +alert(a); // 返回11 +alert(b); // 返回21 +alert(c); // 返回10 + +(12,obj.yy)() // window + + +//// + + +var name = 222 + +var a = { + name: '111', + say() { + console.log(this.name) + } +} + +var fun = a.say +fun() +a.say() + +var b = { + name: '333', + say(fn){ + fn() + } +} + +b.say(a.say) + +b.say = a.say + +b.say() \ No newline at end of file diff --git a/every morning/settimeout with promise.html b/every morning/settimeout with promise.html new file mode 100644 index 0000000..81a886a --- /dev/null +++ b/every morning/settimeout with promise.html @@ -0,0 +1,75 @@ + + + + + + + + Document + + + + + + + \ No newline at end of file diff --git a/every morning/sxbd.html b/every morning/sxbd.html new file mode 100644 index 0000000..a636e16 --- /dev/null +++ b/every morning/sxbd.html @@ -0,0 +1,33 @@ + + + + + + + Document + + + + + + + \ No newline at end of file diff --git a/every morning/toString valueof.js b/every morning/toString valueof.js new file mode 100644 index 0000000..65c2925 --- /dev/null +++ b/every morning/toString valueof.js @@ -0,0 +1,10 @@ +const obj = { + valueOf(){ + return 'valueOf' + }, + toSting(){ + return 'toString' + } +} + +console.log(1+obj) \ No newline at end of file diff --git a/grid_layout/index.html b/grid_layout/index.html new file mode 100644 index 0000000..6087ee2 --- /dev/null +++ b/grid_layout/index.html @@ -0,0 +1,26 @@ + + + + + + + + graid layout + + + + +
+
1
+
2
+
3
+
4
+
5
+
6
+
7
+
8
+
9
+
+ + + \ No newline at end of file diff --git a/grid_layout/style.css b/grid_layout/style.css new file mode 100644 index 0000000..766268d --- /dev/null +++ b/grid_layout/style.css @@ -0,0 +1,87 @@ +/* #grid { + width: 450px; + background-color: #f3f3f3; + text-align: center; + display: inline-grid; + grid-template-columns: repeat(3, 33.3%); + grid-template-rows: 150px 150px 150px; +} + +.item { + text-align: center; + border: 1px solid #fff; + color: #fff; + font-weight: bold; + line-height: 150px +} + +.item:first-of-type { + background: #ef342a +} + +.item:nth-of-type(2) { + background: #00a0a0; +} + +.item:nth-of-type(3) { + background: #a0a0ff; +} */ + +#wrapper{ + display: grid; + /* grid-template-columns: repeat(auto-fill, 99px); + */ + /* grid-template-columns: 150px 2fr 1fr; */ + /* grid-template-columns: 1fr 2fr minmax(200px, 1fr); */ + /* (minmax(100px,1fr))表示列宽不小于100px,不大于1fr */ + /* grid-template-columns: 1fr auto 100px; */ + /* 这种情况下auto只会让元素撑起 */ + grid-template-columns: repeat(3, 33.3%); + grid-template-rows: repeat(3, 100px); + /* grid-row-gap: 10px; + grid-column-gap: 10px; */ + grid-gap: 5px 30px; + grid-auto-flow:row; + } + + .item { + font-size: 4em; + text-align: center; + border: 1px solid #e5e4e9; + } + + .item-1 { + background-color: #ef342a; + } + + .item-2 { + background-color: #f68f26; + } + + .item-3 { + background-color: #4ba946; + } + + .item-4 { + background-color: #0376c2; + } + + .item-5 { + background-color: #c077af; + } + + .item-6 { + background-color: #f8d29d; + } + + .item-7 { + background-color: #b5a87f; + } + + .item-8 { + background-color: #d0e4a9; + } + + .item-9 { + background-color: #4dc7ec; + } \ No newline at end of file diff --git "a/leetcode and mianshi/\346\227\240\351\207\215\345\244\215\347\232\204\346\234\200\351\225\277\345\255\227\347\254\246\344\270\262.html" "b/leetcode and mianshi/\346\227\240\351\207\215\345\244\215\347\232\204\346\234\200\351\225\277\345\255\227\347\254\246\344\270\262.html" new file mode 100644 index 0000000..4d35675 --- /dev/null +++ "b/leetcode and mianshi/\346\227\240\351\207\215\345\244\215\347\232\204\346\234\200\351\225\277\345\255\227\347\254\246\344\270\262.html" @@ -0,0 +1,37 @@ + + + + + + + Document + + + + + \ No newline at end of file diff --git "a/\344\270\223\351\242\230\347\263\273\345\210\227/debounce.html" "b/\344\270\223\351\242\230\347\263\273\345\210\227/debounce.html" index b33bec8..c0a1a3b 100644 --- "a/\344\270\223\351\242\230\347\263\273\345\210\227/debounce.html" +++ "b/\344\270\223\351\242\230\347\263\273\345\210\227/debounce.html" @@ -47,6 +47,28 @@ },wait) } } + + // 第三版如果想要立即执行 + function debounce(fn,wait,immediate){ + var timeout + + return function() { + var context = this + var agrs = arguments + if(timeout) clearTimeout(timeout) + if(immediate){ + var callNow = !timeout + timeout = setTimeout(() => { + timeout = null + }, wait); + if(callNow) fn.apply(context,agrs) + }else { + timeout = setTimeout(() => { + fn.apply(context,agrs) + }, wait); + } + } + } \ No newline at end of file diff --git "a/\344\270\223\351\242\230\347\263\273\345\210\227/throttle.html" "b/\344\270\223\351\242\230\347\263\273\345\210\227/throttle.html" new file mode 100644 index 0000000..0a35fdd --- /dev/null +++ "b/\344\270\223\351\242\230\347\263\273\345\210\227/throttle.html" @@ -0,0 +1,92 @@ + + + + + + + Document + + + +
+ + + + \ No newline at end of file diff --git "a/\344\270\223\351\242\230\347\263\273\345\210\227/\346\225\260\347\273\204\345\216\273\351\207\215.js" "b/\344\270\223\351\242\230\347\263\273\345\210\227/\346\225\260\347\273\204\345\216\273\351\207\215.js" new file mode 100644 index 0000000..1b37857 --- /dev/null +++ "b/\344\270\223\351\242\230\347\263\273\345\210\227/\346\225\260\347\273\204\345\216\273\351\207\215.js" @@ -0,0 +1,67 @@ +var arr = [1,2,1,'1','2','2']; + +/* 双层for循环 +function unique(array) { + var res = [] + var arrlen = array.length + + for(var i=0;i { + return array.indexOf(item) === index + }) +} +*/ + +//es6最简单 + +let unique = (a) => [...new Set(a)] \ No newline at end of file