I am trying to understand the code below, as I am confused about its functionality. In languages like C# or Java, using the base or super keyword usually returns values, whereas in TypeScript, I am receiving "undefined". However, when I switch from using "super" to "this", it seems to work fine.
class Person {
public firstName: string;
public lastName: string;
constructor(fn: string, ln: string) {
this.firstName = fn;
this.lastName = ln;
}
}
class Customer extends Person {
constructor(fn: string, ln: string) {
super(fn, ln);
}
displayDetails() {
console.log(`First Name :${super.firstName}\tLast Name :${super.lastName}`);
}
}
let c = new Customer("Pradeep", "Kumar");
c.displayDetails();
Can someone provide an explanation of how this code is executing?