-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtrain.js
More file actions
43 lines (39 loc) · 1012 Bytes
/
train.js
File metadata and controls
43 lines (39 loc) · 1012 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
39
40
41
42
43
// function throttle(fn, delay) {
// let throttle = false;
// return function(...args) {
// if (!throttle) {
// throttle = true;
// setTimeout(() => {
// fn.apply(this, args);
// throttle = false;
// }, delay);
// }
// };
// }
// let doc = throttle(console.log, 1000);
// setInterval(() => {
// doc("hello");
// }, 100);
// function debounce(fn, delay) {
// let timer;
// return function(...args) {
// clearTimeout(timer);
// timer = setTimeout(() => {
// fn.apply(this, args);
// timer = undefined;
// }, delay);
// };
// }
// function debounce(func, wait) {
// let timeout;
// return function(...args) {
// clearTimeout(timeout);
// timeout = setTimeout(() => {
// func.apply(this, args);
// }, wait);
// };
// }
let deb = debounce(console.log, 1000);
setInterval(() => {
deb("world");
}, 100);