90. write your own `instanceof`

JavaScript
Is this helpful ?

from all members: - 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) // true
myInstanceOf(b, A) // true
myInstanceOf(b, Object) // true

function C() {}
myInstanceOf(b, C) // false
C.prototype = B.prototype
myInstanceOf(b, C) // true
C.prototype = {}
myInstanceOf(b, C) // false

Let's try to solve this problem within 10 mintues.

Discuss(11)