I have the Child class that extends Parent class.
So let say I created a new instance "child" out of the Child class.
When I check the condition child instanceof Child, it returns false.
However, child instanceof Parent returns true.
Why does this so?
EDIT
So I found this only happens when I extend the Child class with Error class. Let me leave the code example below.
class Child extends Error {
constructor(message) {
super(message);
}
}
const ch = new Child();
console.log(ch instanceof Child);
2nd EDIT
class PullCreditError extends Error {
public name: string;
public message: string;
public attemptsRemaining: number;
constructor(message: string, attemptsRemaining: number) {
super();
Error.captureStackTrace(this, PullCreditError);
this.name = 'PullCreditError';
this.message = message;
this.attemptsRemaining = attemptsRemaining;
}
}