0
function myEvent(e) {
    var evtType = e.type
    alert(evtType)
    // displays click, or whatever the event type was
}

how does this work as a call back function? like how does it know that when there is a parameter declared inside a function, it should store an event object in it? is it same for non call back functions too? I don't get it, how does it know that when we declared a variable inside a callback function it will get to store the events automatically , as we never mentioned about it? so what will happen if I give more that one parameter in the callback function?

VLAZ
  • 22,934
  • 9
  • 44
  • 60
  • *"how does this work as a call back function?"* Because the browser passes the event object to the function when it calls it, exactly like `example(42)` passes the number 42 to the function `example`. The name of the parameter is irrelevant, parameters receive their values based on their position. It can be any (valid) name you want, and it will still work. – T.J. Crowder Jul 17 '21 at 15:15

0 Answers0