Online since 1990 Yes! I started with Gopher. I do modern Web Component Development with technologies supported by **all** WHATWG partners (Apple, Google, Microsoft & Mozilla)
I don't think there's much of a difference in readability. Say for example myHandler doesn't use this at all. Would you write this.onclick = e => myHandler(e) to make it clear the event was passed or just this.onclick = myHandler? My general intuition is to try to keep it consistent and I generally prefer to not inline handlers (at least in the final product anyway) as I find it starts to clutter up the event handler registrations. To note things that are handlers versus plain methods I usually do by name onClickonPointerMove etc. so hopefully it would be apparent it takes an event parameter. These might be areas where I might switch to decorators whenever they start landing.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
With lexical scope
bind
is old notationEvent handlers don't need bind either, when you call them properly:
this.onclick = (evt) => this.myHandler(evt)
and not:
this.onclick = this.myHandler.bind(this)
The latter sucks from a code readablity POV, you have no clue a vital parameter is passed
I don't think there's much of a difference in readability. Say for example
myHandler
doesn't usethis
at all. Would you writethis.onclick = e => myHandler(e)
to make it clear the event was passed or justthis.onclick = myHandler
? My general intuition is to try to keep it consistent and I generally prefer to not inline handlers (at least in the final product anyway) as I find it starts to clutter up the event handler registrations. To note things that are handlers versus plain methods I usually do by nameonClick
onPointerMove
etc. so hopefully it would be apparent it takes an event parameter. These might be areas where I might switch to decorators whenever they start landing.