hasInstanceadvancedclass EvenNumber {
static [Symbol.hasInstance](n: unknown) {
return typeof n === 'number' && n % 2 === 0
}
}
2 instanceof EvenNumber // β trueDefine static [Symbol.hasInstance] on a class to override how instanceof checks membership.
A class can define static [Symbol.hasInstance](instance) to customise instanceof.
Challenge: Create a class where all arrays are "instances".