fishbone.js
fishbone.js copied to clipboard
Operator instanceof does not work with subclasses
This does work and prints true:
var A = Model();
var a = new A();
console.log(a instanceof A);
However, the following does not work as expected, and it prints false:
var A = Model();
var B = A.extend();
var b = new B();
console.log(b instanceof A);
Probably needs some fiddling with .prototype, but I haven't figured it out yet.
Would also be acceptable fishbone providing an Klass.instanceof method, or a "plugin" or something like to make Klass.extend method work with prototype... I'd be cool if it come separated from fishbone core, to prevent it from passing 1/2kb...
@nawarian: Being able to use the instanceof operator from the language sounds best, but I would be happy to have something that workds and I don't mind having to use foo.instanceof(FooClass).