The if statement below evaluates to true when type is a string and I can't seem to figure out why. This is my code:
const validateType = (instanceDescription, type) => {
if (!type instanceof Type) {
throw new Error(`type property of ${instanceDescription} is not
a (child) instance of class Type`);
}
}
I can't see the problem being in my class because it's really simple. It looks like this.
class Type {
constructor(key, multipliers) {
this.multipliers = multipliers;
this.key = key;
}
}
Is there something going on with the instanceof comparison that I'm not aware of or am I just going mad. I got around it by checking if a certain property is undefined which it will be for a string but I would rather go for the more clear instanceof option
validateTypefunction, and with what parameters?