Today I Learned

Dynamically accessing static properties of an instance

Use Object.getPrototypeOf(<instance>).constructor.<static-property-name> to access static-property-name of instance. Example:

class Person {
  name = 'person'

  static names = ['simon', 'nomis']
}

class Dog {
  name = 'dog'

  static names = ['kajtek', 'maniek']
}

const person = new Person()
const dog = new Dog()

function displayNames(named: Person | Dog) {
  console.log(`${named.name} - names: ${Object.getPrototypeOf(named).constructor.names}`)
}

displayNames(person)
displayNames(dog)

Results in:

[LOG]: "person - names: simon,nomis" 
[LOG]: "dog - names: kajtek,maniek"