Implement a throttle function
Throttling is a technique used to control how many times we allow a function to be executed over time.
When a JavaScript function is said to be throttled with a wait time of X milliseconds, it can only be invoked at most once every X milliseconds.
The callback is invoked immediately and cannot be invoked again for the rest of the wait duration.
From my personal experience, the implementation of debouncing with following variations are usally asked:
1. Basic throttle implementation
2. Variation with last result
In this variation it is expected that during the throlling period if the function is invoked again, we simply return the last result.
Further Reading
I strongly encourage you to explore and tackle additional questions in my Closure Questions for Frontend Interviews blog series.
By doing so, you can enhance your understanding and proficiency with closures, preparing you to excel in your upcoming frontend interviews.
Wishing you best. Happy Interviewing 🫡.