JavaScript · Middle · Question 8 of 75
What are classes in JavaScript really?
- ✓Correct answer: Syntax on top of prototypal inheritance with a few extra checks
- 2A separate inheritance model that fully replaced prototypes
- 3Compile-time-only structures, like TS interfaces
Explanation
Class methods go into Class.prototype, and extends builds the prototype chain. But there are differences from constructor functions: a class can't be called without new, its body runs in strict mode, methods are non-enumerable, and there are private #x fields and static.