90. `instanceof`を実装する

JavaScript

少し工夫が必要  - accepted / - tried

instanceOf の働きは知っていますか?

知っていれば、 myInstanceOf()を実装してください。

class A {}class B extends A {}const b = new B()myInstanceOf(b, B) // truemyInstanceOf(b, A) // truemyInstanceOf(b, Object) // truefunction C() {}myInstanceOf(b, C) // falseC.prototype = B.prototypemyInstanceOf(b, C) // trueC.prototype = {}myInstanceOf(b, C) // false

常にもっといい方法を求めよう。