First, instanceof
is used to determine whether the prototype of a certain constructor exists on a certain instance object.
SmsClass instanceof Function ? "":SmsClass
Let's go straight to the code
export function instanceofFn(Left, Constructor) {
const ConstructorP = Constructor.prototype;
Left = Left.__proto__;
// Keep looking up
while (true) {
if (Left === null) {
return false;
}
if (Left === ConstructorP) {
return true;
}
// Continue to search the prototype chain upwards
Left = Left.__proto__;
}
}