What's the difference between an ES6 class and a constructor function?
Quick answer
Mostly syntax. Classes are sugar over prototypes, but they're not hoisted, always run in strict mode, and must be called with `new`.
In detail
Methods in a class body land on Class.prototype, `extends` wires the prototype chain and `super` calls the parent — the same mechanics as constructor functions. Differences: classes are block-scoped and not hoisted, their bodies are strict mode, and calling a class without `new` throws (a constructor function wouldn't).
1class Animal {
2 constructor(name) { this.name = name; }
3 speak() { return `${this.name} makes a sound`; }
4}
5class Dog extends Animal {
6 speak() { return `${super.speak()} — a bark`; }
7}Why interviewers ask this: Checks whether you see classes as sugar, not magic.
This is 1 of 118+ questions in the JavaScript Interview Kit
Get every question with detailed answers, follow-ups and real code — plus coding challenges and a last-minute revision sheet. One-time payment, instant access.
⚡ Get the JavaScript Interview Kit → ₹299