Rob's garden / notes / note

Note

#TIL you can change the implementation of #JavaScript's instanceof operator using Symbol.hasInstance

export class TheAnswer {
  static [Symbol.hasInstance](value) {
    return value == 42;
  }
}

then

// true
42 instanceof TheAnswer

There's more cool stuff about Symbol here: