In Javascript, is it at all possible to make function Foo()
such that both (Foo() == Foo)
, and (Foo() instanceof Foo)
?
This almost works:
function Foo() { Object.setPrototypeOf(Foo,this); return Foo; }
so new Foo() instanceof Foo
in this case, but if I just call Foo
without new
, it doesn't work.