)
}
}
)
(
}
{
)
)
(
)
(
(
{
}
)
(
)
}
)
)
{
(
(
)
)
}
)
(
}

super Methods Javascript

  1. class Person {
  2.   constructor(name, email) {
  3.     this.name = name;
  4.   }
  5.   toString() {
  6.     return `name: ${this.name}`;
  7.   }
  8. }
  9.  
  10. class Teacher extends Person {
  11.   constructor(name, subject) {
  12.     super(name);
  13.     this.subject = subject;
  14.   }
  15.   toString() {
  16.     return super.toString() + ` subject: ${this.subject}`;
  17.   }
  18. }
  19.  
  20. const teacher = new Teacher('testname', 'testSubject');
  21. console.log(teacher.toString());

This is from an old stackoveflow answer of mine

snippet.zone ~ 2021-24 /// {s/z}