Learn JavaScript
❯ classes_oop.super

super: Parent Access in JavaScript

$concept

super reaches the parent in two forms: super(...) as a constructor call (mandatory before this in derived constructors) and super.method() for parent method invocation (overrides extending rather than replacing behavior). In object literals, super similarly accesses the prototype — methods-only syntax, since the home-object reference needs method definitions.

Call super() with the arguments the parent requires, then specialize; call super.method() when overriding wraps rather than replaces (validation plus parent logic). Forgetting super() before this is a ReferenceError, not a subtle bug.

$how it works
1

Construct parent first

super(name) in a derived constructor builds the base subobject — this is unusable until it runs.

2

Extend methods via super

render() { super.render(); this.extra(); } — parent behavior plus specialization, not either/or.

3

Missing super throws

Touching this before super() is a loud ReferenceError — the language enforces construction order.

4

Methods only

super works in method definitions (classes and literals) — arrow properties and detached functions lack home objects.

$example
class Animal {
constructor(name) {
this.name = name;
}
label() {
return "animal:" + this.name;
}
}
class Dog extends Animal {
label() {
return super.label() + "!";
}
}
console.log(new Dog("Rex").label());
Output
animal:Rex!
1Dog's implicit constructor forwards to Animal's, initializing name.
2Dog's label calls the parent version via super, then appends ! — extension, not replacement.
3animal:Rex! prints — layered behavior through two classes.
$use cases
Initializing inherited state through parent constructors
Wrapping parent methods with pre/post logic in overrides
Prototype-method super calls in object literals
Reading must-call-super errors as construction-order enforcement

Recommended resourcesAffiliate links · may earn us a commission

Recommended for learners

Structured coding coursesVideo courses that pair well with visual practice — pick one language and go deep.Browse courses Pro code editor & AI assistantWrite, debug and explain code faster while you practice the patterns here.Try it free Classic DSA interview booksThe reference books interviewers themselves learned from — great next to the visualizers.See the books

Practice what you learned

Re-implement each visualized algorithm in JavaScript yourself — building beats watching.