-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscratch.js
97 lines (76 loc) · 1.5 KB
/
scratch.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
var foo = function foo () {
console.log(this);
console.log(arguments[0]);
if( ! arguments[0] ) {
return {};
}
return this;
};
var ap = Symbol("ap1");
var ap = Symbol("ap2");
foo(({
a : "" ,
b : setTimeout.bind(function () {
}) ,
})).
foo(({
c () {
} ,
[ap] : () => {
} ,
})).
foo();
a = ((() => {
let cs = function cs () {
return {
c : cs.caller ,
};
};
let c = {
sd () {
console.log(cs);
} ,
};
return function () {
console.log(cs().c);
};
})());
//函数节流
window.onresize = function () {
};
//封装一个事件委托函数
cc = document.querySelector("div");
document.body.addEventListener(
"click" ,
(e) => {
for ( let i of e.path ) {
if( i === cc ) {
console.log(i);
}
}
} ,
);
//事件委托函数
/**
*
* @param type {string}
* @param delegationEl {HTMLElement}
* @param targetEl {HTMLElement}
* @param method {function}
*/
function eDelegation (type ,
delegationEl ,
targetEl ,
method) {
delegationEl.addEventListener(
type,
method
)
};
eDelegation(
"click" ,
document.body ,
document.querySelector(`div[#csd]`),
(e) => {
},
);