fishbone.js icon indicating copy to clipboard operation
fishbone.js copied to clipboard

Operator instanceof does not work with subclasses

Open aperezdc opened this issue 11 years ago • 2 comments

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.

aperezdc avatar Mar 05 '14 06:03 aperezdc

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 avatar Aug 18 '14 14:08 nawarian

@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).

aperezdc avatar Sep 02 '14 11:09 aperezdc