How to detect whether EcmaScript class has its own constructor? See code snippet below.
class Person {
constructor(name, age) { // <- Own constructor
this._name = name;
this._age = age;
}
}
class Manager extends Person {
// This class does not have it's own constructor
}
It seems there is no clear way to do this check.
Thank you all for time and help.
Personhas its own constructor and classManagerdon't.classandconstructoryou are NOT making classes and constructors Instead you are defining a function and maybe adding things to its prototype. I really don't see how this question (while interesting) has a relevant answer, because classes aren't real in JavaScript. Are you asking whether at run time you can see what the source code looked like? I think it is impossible without major hacks....