-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex copy.html
More file actions
38 lines (37 loc) · 826 Bytes
/
Copy pathindex copy.html
File metadata and controls
38 lines (37 loc) · 826 Bytes
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
<html>
<title>算法debug大法</title>
<body>
<div id="btn">
<button>1</button>
<button>2</button>
<button>3</button>
<button>4</button>
<button>5</button>
<button>6</button>
<button>7</button>
</div>
<script>
function debounce(fn, time) {
let lockTime = null;
return function(...args) {
clearTimeout(lockTime);
lockTime = setTimeout(() => {
fn(...args);
}, time)
}
}
function throttle(fn, time) {
let target = true;
return function(...args) {
if(target) {
target = false;
setTimeout(() => {
fn(...args);
target = true;
}, time);
}
}
}
</script>
</body>
</html>