Classes are a great tool, but they're not the only tool. JavaScript is flexible, and lots of excellent JavaScript code uses few or no classes at all.
| Use a class when... | Use plain objects and functions when... |
|---|---|
| You need many objects of the same type, with the same methods | You just need to hold some data |
| Objects have state that changes over time, with rules about how | Your functions just take inputs and return outputs |
| You want encapsulation (private data) | Simple is enough |
| You're modeling things (users, characters, accounts, shapes) | You're transforming data (like the array methods in Grade 10) |
Many developers mix both styles: classes for the "things" in their app, and plain functions for processing data. That's perfectly fine!