I'd like to check the class of an object, such as this:
class Foo {}
var foo = new Foo();
I saw this post In ES6, how do you check the class of an object? that correctly says I can use
if (foo instanceof Foo) { ... }
Is there a way to do this without having to require every class I want to check for into the file? If I am doing it with foo instanceof Foo
, for lots of classes, I have to require each one into the file (often for only that purpose).
Is there another way?
via Sir Robert
No comments:
Post a Comment