Dev HelpersOpen library
← Back

Call the parent method from a subclass

Call the parent method from a subclass in JavaScript.

Open this example in the interactive library

Source code

class Label {
  text() {
    return "draft";
  }
}
class TaggedLabel extends Label {
  text() {
    return "[" + super.text() + "]";
  }
}
console.log(new TaggedLabel().text());

Sample output

[draft]