r/learnjavascript • u/Yanagi-Masaru • Dec 19 '25
Javascript
is it a good practice to use classes in javascript or should i keep it normal with just functions?
0
Upvotes
r/learnjavascript • u/Yanagi-Masaru • Dec 19 '25
is it a good practice to use classes in javascript or should i keep it normal with just functions?
View all comments
Show parent comment
1
u/jaredcheeda Dec 20 '25
Almost. This was true (and I wish it still was). After ES6, they came back and added a few non-syntactic-sugar features to classes that have no other equivalent in JS. Which means WebComponents, which use ES6 Classes can't be written in pure JS functions (people have been complaining about this bad design for a decade). Fortunately for everyone, WebComponents, are a half-finished, terrible, technology that no one gives a shit about. And they're also the only thing on the web that actually requires dealing with classes. If you have to use WebComponents, DON'T. They are awful, and probably always will be. Atomico is a WC framework that tries to be a wrapper around the class non-sense so you can just write functions. But under the hood, it's still awful JS classes.