Interviewing for Front-End Engineers Timing: Debounce Exercise
Transcript from the "Timing: Debounce Exercise" Lesson
[00:00:57] We'll talk about request animation frame for a different sort of timing, but I didn't wanna mix that up into here. All right, so talking about timing, what is debounce?
>> It's a way to throttle things, so you don't do it too much, I guess.
>> Yeah, that's exactly right, it's a way of slowing something down.
[00:01:21] A good way of thinking about debounce is autocomplete search. I don't want every single character that I type to be firing off requests. So if I'm typing, how do I become tall like Jem, that means as long as that sentence is, that means I'm firing off every single request, so we wanna debounce that.
[00:01:39] So we wanna set the debounce to, say, 500 milliseconds. So that means, whenever someone stops typing, that's when the debounce is gonna fire. So let's implement debounce. I actually got this one on a phone screen not too long ago. So I'm not just making these questions up to be hard.
[00:01:58] These are real questions that people ask. And it's a fascinating insight into someone's understanding, setting my debounce. I'll give you a hint, you're gonna need either setInterval or setTimeout. I would probably use setTimeout, but you do you.