function customInstanceof(obj, constructor) {
if (typeof obj !== 'object' || obj === null) {
return false;
}
let proto = Object.getPrototypeOf(obj);
while (proto !== null) {
if (proto === constructor.prototype) {
return true;
}
proto = Object.getPrototypeOf(proto);
}
return false;
}
function Person(name) {
this.name = name;
}
const person = new Person('Alice');
console.log(customInstanceof(person, Person));
console.log(customInstanceof(person, Object));
console.log(customInstanceof(person, Array));
console