'How does a pointer event passed as an argument in debounce?
I am confused about how the pointer event is passed to the debounce() in addEventListener(). For the constant variable multiply it takes the two arguments which are passed as args in debounce(). However, when it is used in .addEventListener() I only see the syntax that defines the function. So how does the pointer event is passed as an argument like the first example?
function debounce(func, timeout = 1000) {
let timer;
return (...args) => {
if (timer) clearTimeout(timer);
timer = setTimeout(() => {
func(...args);
}, timeout);
};
}
const multiply = debounce((x, y) => console.log(x * y));
multiply(10, 10); //I see that this takes the arguments that assign to x and y
button.addEventListener(
"click",
debounce((e) => console.log("clicked")));
//but here I am confused how the pointer event is being passed as an argument
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
