The super Keyword — JS Technical Interview Questions & Answers
Calling the parent constructor or methods.
The super Keyword
- The super Keyword (js) is a JS topic. In plain words you use it for a short The super Keyword js example in a script in the browser. Don’t start with a slogan — start with that picture.
- Smallest example: the smallest The super Keyword js example you can type. Type it, run it, and say what you see. If you can do that from memory, you know The super Keyword (js).
- From the example next to this theory: Calling the parent constructor or methods.
- Trap: only saying “The super Keyword js” with no example. Fix that before you talk about advanced JS.
- Viva: what is The super Keyword (js)? Then show the smallest The super Keyword js example you can type. Then name the trap.
Technical Interview Tip: What is The super Keyword (js)? Show this: the smallest The super Keyword js example you can type. Trap: only saying “The super Keyword js” with no example.
Code Examples for The super Keyword
The super Keyword — working example
class Person {
constructor(name) {
this.name = name;
}
greet() {
return "Hi " + this.name;
}
}
class Student extends Person {
constructor(name, track) {
super(name);
this.track = track;
}
}
const s = new Student("Ada", "JS");
console.log(s.greet(), s.track);
console.log(Object.getPrototypeOf(s) === Student.prototype);The super Keyword — eS classes are sugar over prototypes; extends sets up the prototype chain; super calls the parent.
How to Explain The super Keyword to an Interviewer
What is The super Keyword (js)?
Used for a short The super Keyword js example a script in the browser Not just the heading
Give one small example of The super Keyword (js).
the smallest The super Keyword js example you can type Calling the parent constructor or methods
What mistake do beginners make with The super Keyword (js)?
only saying “The super Keyword js” with no example Show the fix
Where do you use The super Keyword (js)?
a script in the browser a short The super Keyword js example