90. `instanceof`を実装する
シェアしよう
少し工夫が必要 - accepted / - tried
instanceOf の働きは知っていますか?
知っていれば、 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