Skip to content
This repository was archived by the owner on Sep 1, 2024. It is now read-only.
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 24 additions & 2 deletions problem/implement-basic-debounce_en.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,26 @@
## Very basic implementation of debouncing.

There is no solution yet.

Would you like to [contribute to the solution](https://github.com/BFEdev/BFE.dev-solutions/blob/main/problem/implement-basic-debounce_en.md)? [Contribute guideline](https://github.com/BFEdev/BFE.dev-solutions#how-to-contribute)
```javascript

// This is a JavaScript coding problem from BFE.dev

/**
* @param {(...args: any[]) => any} func
* @param {number} wait
* @returns {(...args: any[]) => any}
*/
function debounce(func, delay) {
let timeoutID;

return function(...args) {
//Clearing the timeout to avoid previous function call
clearTimeout(timeoutID);
//New function is passed to the setTimeout using the JS bind method.
timeoutID = setTimeout(func.bind(this, ...args),delay);
}
}



```