0
<button onClick="this.handleClick">

handleClick(event){
  console.log(event.target)
}

Why does the event argument in the handleClick function work without passing it as an argument? Does every event handler by defult create an event parameter?

jpj
  • 83
  • 1
  • 6
  • "Does every event handler by defult create an event parameter" yes, a new one is created every time it is e.g. clicked. – Toastrackenigma Aug 19 '20 at 11:13
  • you "give" `onClick` a function that takes the event as the fist argument. `this.handleClick` is a function. An alternative is something like `onClick="function(e){ handleClick(e) }"` – Jan Stránský Aug 19 '20 at 11:14
  • when javascript will call that handler function, it will pass the `Event` object. So you don't have to explicitly pass it. – Yousaf Aug 19 '20 at 11:15
  • Does this answer your question? [Why does RxJS subscribe allow omitting the arrow function and the following method argument?](https://stackoverflow.com/questions/63187528/why-does-rxjs-subscribe-allow-omitting-the-arrow-function-and-the-following-meth) – arslan2012 Aug 19 '20 at 11:15

0 Answers0