DEV Community

Discussion on: Rethinking JavaScript: The complete elimination and eradication of JavaScript's this.

Collapse
 
filipekiss profile image
Filipe Kiss • Edited

I see where you are coming from and proposing new alternatives is always great, but in this case I, personally, think that nothis or fixthis are not a good approach. Unless JavaScript is completely redesigned in the years to come to make this work as expected (and I seriously doubt it. named functions and arrow functions already treat this differently, so you just choose what to use) and prevent all those pesky "gotcha!" moments we have every once in a while, adding a new dependency and new layer of complexity won't make anyone a better developer. It's far more useful to understand how this works and how you can use bind, call and apply to circumvent those problems then to add a new dependencie that will only mask those problems. I'd rather have someone on my team come to me and say "hey, I don't know why this isn't binding correctly" than see fixthis(this) on the code. this is not broken. It doesn't need to be fixed. this is just a rebelious teenager which we, sometimes, can't comprehend. Understand how this works and you'll see that correctly binding it is a far superior choice in the longterm than adding a dependency.

Collapse
 
joelnet profile image
JavaScript Joel

Unless JavaScript is completely redesigned in the years to come to make this work as expected (and I seriously doubt it

I agree. Can't be redesigned. It needs to remain backward compatible, so this will always remain and function as it does.

What I am proposing is the same thing others have proposed when suggesting programming languages should eliminate NULL (now considered the Billion dollar mistake).

If we can write our software in a way that eliminates an entire class of bugs, why would we not choose to do so?

If NULL is considered the Billion dollar mistake, how much is this going to cost us?