Skip to solution
hardFrontend

Explain how prototypal inheritance differs from classical inheritance.

748 views
01

Understand the problem

Question presented to candidate: "How does the way inheritance works in JavaScript actually differ from classical, class-based inheritance in a language like Java or C++?"

What a strong answer should cover:

  • Classical inheritance is a blueprint-and-instance model: a class is a fixed template, checked and fixed at compile time, and objects are stamped out from it.
  • Prototypal inheritance is an object-to-object delegation model: there are no blueprints -- objects link directly to other live objects, and lookup happens dynamically at runtime.
  • Delegation vs copying: a prototypal object does not receive a private copy of its prototype's methods -- it looks them up live, every time, by following a real link.
  • Dynamic vs static: a JavaScript prototype can be patched or extended after instances already exist, and every existing instance picks up the change immediately -- a compiled Java class cannot be altered at runtime.
  • Even JavaScript's class keyword does not introduce true classical inheritance underneath -- it is syntax sugar over the exact same prototype chain, and a class's methods remain a live, mutable object (Ctor.prototype) that can still be patched after the fact.

Clarifying questions expected:

  • "Should I focus on the conceptual difference, or also cover exactly how the JavaScript prototype mechanism itself works?" (the mechanism has its own dedicated question)

Code / implementation expected: Yes -- a runnable snippet proving a class's prototype is still live and patchable after declaration, unlike a compiled classical class.

prototypesinheritanceoopclasses
02

Attempt it yourself

Sketch your approach before reading the solution — that's what interviews test.

Nudge consolestandby

Stuck? Beam a request up — the console returns a conceptual nudge that guides your logic without spoiling the implementation.

03

Study the solution

Target Audience: Engineers preparing for JavaScript object-model interview questions that expect a comparison to classical OOP. Difficulty: Hard

How to read this doc: Concepts are explained in plain language first, then tagged with 📌 Interview term:. Every result below was actually run on N

Solution ready — 2 min read

Classified // press E to declassify

04

Run the code

JSA class prototype stays a live, patchable object -- even after existing instances are created (run directly)
05

Join the discussion

Discussion (0)

Sign in to join the discussion.

No responses yet. Be the first to share what you think.

Transmission complete // awaiting log

KEEP THE
STREAK ALIVE.

Dossier 136 of 165 decoded in the JavaScript track. One more won't hurt.

Back to track