Ridiculous. this isn't that bad, surely not bad enough to make such a big of deal over it. So, don't write an arrow function if you need to use this. It's not a big deal. Sure, the language should make it available on that situation and it's poor design that they didn't, but it's not the end of the world to use a different function form when necessary.
Cofounded Host Collective (DiscountASP.net). Cofounded Player Axis (Social Gaming). Computer Scientist and Technology Evangelist with 20+ years of experience with JavaScript!
For experienced programmers, this isn't much of an issue. We are aware of the problems and how to correctly use it.
Though for the rest of the JavaScript programmers that have yet to achieve that level of experience, they will surely stumble on this. (as stack overflow questions suggest).
Bug with this are guaranteed. I have not seen a single JavaScript developer that hasn't written console.log(this) just to try and figure out WHAT IS THIS.
The best solution is to not program with this at all. Use a functional reactive style.
The library is just days old and needs a lot of work for sure. But take a look at this code (nothis v1.2.1). I would say this is more readable because of nothis.
importReactfrom'react'importnothisAllfrom'nothis/nothisAll'// 🔥 LIT: no this in sight!classCounterextendsReact.Component{state={count:0}constructor(){super()nothisAll(this)}increment({setState}){setState(({count})=>({count:count+1}))}render({increment,state}){return(<div><buttononClick={increment}>{state.count}</button>
</div>
)}}
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.
Ridiculous. this isn't that bad, surely not bad enough to make such a big of deal over it. So, don't write an arrow function if you need to use this. It's not a big deal. Sure, the language should make it available on that situation and it's poor design that they didn't, but it's not the end of the world to use a different function form when necessary.
For experienced programmers,
this
isn't much of an issue. We are aware of the problems and how to correctly use it.Though for the rest of the JavaScript programmers that have yet to achieve that level of experience, they will surely stumble on
this
. (as stack overflow questions suggest).Bug with this are guaranteed. I have not seen a single JavaScript developer that hasn't written
console.log(this)
just to try and figure out WHAT IS THIS.The best solution is to not program with
this
at all. Use a functional reactive style.The library is just days old and needs a lot of work for sure. But take a look at this code (nothis v1.2.1). I would say this is more readable because of
nothis
.