I have a question about JavaScript's native addEventListener
, normally we are using it like js selectElement.addEventListener('change', (event) => { const value = event.target.value });
but today I was looking at the type definition for it in TypeScript, it says the callback we pass into the addEventListener
has this signature
(this: HTMLElement, ev: HTMLElementEventMap[K]) => any
so the first param it takes is actually an html
element. I am a bit confused as we normally treat the first param as an event object as in my first example there.