File tree Expand file tree Collapse file tree 1 file changed +1
-38
lines changed Expand file tree Collapse file tree 1 file changed +1
-38
lines changed Original file line number Diff line number Diff line change 1
1
// Question Link: https://leetcode.com/problems/debounce/?envType=study-plan-v2&envId=30-days-of-javascript
2
- // Solution Link:
2
+ // Solution Link: https://leetcode.com/problems/debounce/solutions/5446184/javascript-easy-solution/
3
3
4
4
/*
5
5
2627. Debounce
@@ -92,40 +92,3 @@ var debounce = function(fn, t) {
92
92
* log('Hello'); // cancelled
93
93
* log('Hello'); // Logged at t=100ms
94
94
*/
95
-
96
-
97
-
98
-
99
-
100
-
101
-
102
- 🎯 Easy JavaScript Solution🔥
103
-
104
- # Code:
105
- `` `
106
- /**
107
- * @param {Function} fn
108
- * @param {number} t milliseconds
109
- * @return {Function}
110
- */
111
- var debounce = function(fn, t) {
112
-
113
- let timerId = undefined;
114
-
115
- return function(...args) {
116
-
117
- clearTimeout(timerId);
118
- timerId = setTimeout(fn, t, ...args);
119
- }
120
- };
121
-
122
- /**
123
- * const log = debounce(console.log, 100);
124
- * log('Hello'); // cancelled
125
- * log('Hello'); // cancelled
126
- * log('Hello'); // Logged at t=100ms
127
- */
128
- ` ``
129
-
130
-
131
- ! [ upvote . jpeg ] ( https :/ / assets . leetcode . com / users / images / 6 fde666b - f5a1 - 40 af - 80 f3 - 0200 b3f24634_1720428311 .467689 . jpeg )
You can’t perform that action at this time.
0 commit comments