I have a function that was previously working; but I have to make it wait now with setTimeout
. I thought I could just add an arrow function as the callback for the eventListener and still be able to pass this
as the button for the context but I am getting an error.
button.addEventListener("click", () => {
setTimeout(checkAndRespond,1500);
});
//This is the line that throws the error
checkAndRespond = async function () {
...
const row = this.parentElement.parentElement;
...
}
How am I supposed to pass this
into the inner function?
Is the setTimeout context being passed in as this
to checkAndRespond?
Is there something i am not understanding about how arrow functions work?