Trying To Figure Out Josh W. Comeau's Debouncer In An Event Listener
I'm using Josh's debouncer script snippet. I've got it working using a `const doUpdate1 = debounce((event) =< {}, 100)`` approach, but can't figure out how to do it if the function is defined with `function``.
Details
Josh's script looks like this:
JavaScript
let timeoutId = null;
return
window.;
timeoutId = window.;
};
}
Given these two buttons:
HTML
Clicker 1
Clicker 2
This is breaking my understanding of javascript a little. I thought using `return`` in `doUpdate2`` would produce the same result.
I'm not sure what's going on here. I'm over on Mastodon if you've got suggestions.