The typeof operator returns a string indicating the type of the
unevaluated operand
you need instanceof, isPrototypeOf
class Bar{}
class Foo extends Bar {}
var n = new Foo();
console.log(n instanceof Bar); // true
console.log(Bar.isPrototypeOf(Foo)); // true
console.log(Foo.prototype instanceof Bar); // true
As ES6 classes inherit prototypically from each other, you can use
isPrototypeOf
Alternatively just go with the usual
instanceof
operator:MDN for
typeof
:you need
instanceof
,isPrototypeOf