90. write your own `instanceof`

JavaScript

medium  - accepted / - tried

Do you know how instanceOf works ?

If so, please write you own 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

Always try to find a better approach.