// myInstanceof(child, parent)
function myInstanceof(child, parent) {
if (!child || typeof child !== 'object') {
return false;
}
let temp = child;
while(temp.__proto__) {
if (temp.__proto__ === parent.prototype) {
return true;
}
else {
temp = temp.__proto__;
}
}
return false;
}
class Animal {
}
class Dog {
}
class Cat extends Animal {
}
const dog = new Dog();
console.log(myInstanceof(dog, Dog));
const cat = new Cat();
console.log(myInstanceof(cat, Animal));