javascript - Check if class constructor extends another class -
this question has answer here:
- check if constructor inherits in es6 2 answers
how can check if class constructor extends class, without constructing object? ie constructor reference.
example
class { } class b extends { } var b = b; if(typeof b === b)
you can check of instanceof
below.
class { } class b extends { } class c { } console.log(b.prototype instanceof a); console.log(c.prototype instanceof a); // instance var b = new b(); console.log(b instanceof b); console.log(b instanceof a); console.log(b instanceof c);
Comments
Post a Comment