Say I have
function Foo() {
// stuff
}
Foo.prototype.bar = function() {
return new Bar();
}
function Bar() {};
module.exports = Foo;
Now say I have
const foo = new Foo();
console.log(foo instanceof Foo); // true
const bar = new Foo().bar();
console.log(bar instanceof Foo); // false
console.log(bar instanceof Foo.prototype.bar); // false
Here Bar is never exported. So how can I test if bar is an instance of ... something? Can I somehow have bar instanceof Foo or a subset of Foo or something?