import { Dog } from "./dog"; import { Cat } from "./cat"; import { Animal } from "./animal"; // because cat and dog are subclasses of animal, they can be stored in an array of animals const animals: Animal[] = [ new Dog('buster'), new Cat('mittens') ] for (const a of animals) { // when calling the make_sound function, the implementation of the actual class gets called (in this case cat or dog) a.make_sound(); }