DEV Community

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

Collapse
 
inf3rno profile image
inf3rno

Well it is hard to follow what you want to achieve here. If you don't like "this" in javascript classes, then try a procedural or functional approach instead or choose a different languge e.g. java, which uses "this" rarely, if you insist to oop.

Collapse
 
joelnet profile image
JavaScript Joel

I'm not sure what is so hard to follow. I could boil it down to 3 words: Stop using this.

The articles I write all preach a functional reactive paradigm. You might enjoy How I rediscovered my love for JavaScript after throwing 90% of it in the trash.

While my code doesn't require the use of this, there are many 3rd party libraries which force you to use this.

Example:

const events = new EventEmitter2({ wildcard: true })

events.on('button.*', function() {
  console.log('event:', this.event)
})

events.emit('button.click')

or choose a different languge

The "If you don't like it go somewhere else approach" is not a solution.