DEV Community

Discussion on: Tired of Guessing What 'this' Is Referring To?

 
jdforsythe profile image
Jeremy Forsythe • Edited

I don't write React code. I'm a full stack JS dev and avoid classes like the plague, when possible. Sure, every JS dev should understand the keyword, and I didn't mean to suggest otherwise. I just don't find many reasons to ever use a class beyond creating new Error classes or using a library that requires it. There are so many ways to accomplish similar things.

Also, it's not just the React community moving toward functional programming. I'd bet there are as many companies using functional techniques as classes. Ever use Array.map? Or lodash.filter? Promises and Observables are (basically) Monads. We got arrow functions and Array.prototype methods specifically because of the rise in FP in JS. I highly suggest Eric Elliot's series on Medium about FP, especially the "Forgotten History of OOP" medium.com/javascript-scene/the-fo...

I'm not a FP fanboy, either. It's just another tool that is useful sometimes. And if I find a place I need a class beyond what I said above, I would use it. I just can't think of many use cases where I need one.