JavaScript › Classes & Class Syntax
What is a class in JavaScript, and is it a new kind of object model?
BeginnerAnswer
A class is syntactic sugar over JavaScript's existing prototype-based inheritance. It doesn't add a new object model — under the hood, methods still live on the prototype object, just written with cleaner syntax.
class Animal {
constructor(name) { this.name = name; }
speak() { return `${this.name} makes a sound.`; }
}
const a = new Animal('Rex');
console.log(a.speak());Real-world example Modeling domain entities like User, Order, or Product with clear, readable structure.