DEV Community


Discussion on: I Don't Use JavaScript Classes At All. Am I Missing Out on Something?

manonbox profile image

I use classes when it makes sense from a readability point of view. Whenever I find myself writing a bunch of functions that are related, take in similar or same inputs (i.e. a bunch of related functions all depending on similar variables) then I think you can move this to a class.

This allows you to group your functions together, and reduce or eliminate the arguments they take, as they can use properties set by the constructor.

You can achieve exactly the same by not using a class. You can write lots of functions in a module, or simulate a class behaviour with a closure. You can always get the same result by not writing classes, but I would challenge if they are as readable as a simple class.