home ~ socials ~ projects ~ rss

Call An Event Handler For A Function In A JavaScript Class

August 2023

TODO: See this first and consolidate: 2ai9647o


I thought that you had to put calls to class functions in like this:

pingButton.addEventListener("click", () => {
  w.ping()
})

But this work fine:

pingButton.addEventListener("click", w.ping)

I need to go back and look at the code that send me down this path of investigation to figure out what else was up

end of line
Share link:
https://www.alanwsmith.com/en/2u/go/7u/lx/?call-an-event-handler-for-a-function-in-a-javascript-class