Skip to content

Commit ab1f174

Browse files
authored
code added
1 parent 26603e5 commit ab1f174

File tree

1 file changed

+1
-38
lines changed

1 file changed

+1
-38
lines changed

18_debounce.js

Lines changed: 1 addition & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// 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/
33

44
/*
55
2627. Debounce
@@ -92,40 +92,3 @@ var debounce = function(fn, t) {
9292
* log('Hello'); // cancelled
9393
* log('Hello'); // Logged at t=100ms
9494
*/
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/6fde666b-f5a1-40af-80f3-0200b3f24634_1720428311.467689.jpeg)

0 commit comments

Comments
 (0)