Classes

Object-oriented programming bundles data with the methods that act on it. Before ES2015 you wired a constructor function's prototype by hand (OOP the Classical Way); class is cleaner syntax over the same machinery (prototype, this and new), and ES2022 added fields, private members and static blocks. Good class design follows SOLID: single responsibility, open for extension but closed for modification, Liskov substitution, interface segregation and dependency inversion.

Subsections