90. write your own `instanceof`
Share
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
Related Lists
the good and bad bits of JavaScript