JavaScript super

Beginner
6 min read
Updated: Nov 2026

Definition and Usage

In a class that extends another, super refers to the parent. Use super() in the constructor before this, and super.method() to call parent methods.

JavaScript Syntax

JavaScript
class A {
  hello() { return "A"; }
}
class B extends A {
  hello() { return super.hello() + "B"; }
}
console.log(new B().hello());
Try it Editor

How It Works

  1. extends. B inherits from A.
  2. super.hello(). Runs A's method.
  3. Combine. Returns AB.

Examples

Example 1 — super() in constructor

Must call before this.

JavaScript
class A { constructor(n) { this.n = n; } }
class B extends A {
  constructor(n) { super(n); this.extra = true; }
}
console.log(new B(1).n);
Try it Editor

How It Works

  1. super(n) initializes the parent part.

Example 2 — super in static

Works for static methods too.

JavaScript
class A { static id() { return 1; } }
class B extends A { static id() { return super.id() + 1; } }
console.log(B.id());
Try it Editor

How It Works

  1. super refers to the parent constructor in statics.

Example 3 — See extends

Full inheritance page.

JavaScript
console.log("use class extends with super");
Try it Editor

How It Works

  1. Classes page covers inheritance structure.

Frequently Asked Questions

No in derived constructors—call super() first.
Yes in concise methods when the object is in a class or object with __proto__/setPrototype patterns; prefer classes for clarity.

CODETOFUN NEWS

Stay Ahead in Tech

Get the latest IT news, programming updates, and technology trends directly on your phone.

Your daily dose of tech, straight to your feed.

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

6 people found this page helpful