CodeZettaInterview Hub

JavaScript · OOP · Fresh / Intern · Concept

How does object-oriented programming work in JavaScript compared to classical OOP languages?

Short Interview Answer

JS is prototype-based; ES6 classes are syntactic sugar over constructor functions and prototypes, with some semantic differences (e.g. non-callable without `new`).

Detailed Explanation

Instead of class-copy inheritance (classical), JS links objects via prototypes. You can still model encapsulation, inheritance, and polymorphism. `class` syntax provides constructors, `extends`, `super`, static members, and private fields (`#`), but underneath instances still delegate to prototypes. Objects are dynamic: properties can be added at runtime. Mixins and composition are idiomatic alternatives to deep hierarchies. Interviewers often want you to acknowledge both the prototype model and modern class ergonomics.

Interview Tip

Say 'prototype-based with class sugar' — concise and accurate.

Common Mistake

Claiming JS had no OOP before `class`.

Did you know this answer?