Questions
1.1 TypeScript, please! Let’s keep our promise: convert the JavaScript examples provided in this chapter into TypeScript.
1.2 Classes as first-class objects: We learned that functions are first-class objects, but did you know that classes also are? (Though, of course, speaking of classes as objects does sound weird.) Look at the following example and see what makes it tick! Be careful: there’s some purposefully weird code in it:
const makeSaluteClass = (term) => class { constructor(x) { this.x = x; } salute(y) { console.log(`${this.x} says "${term}" to ${y}`); } }; const Spanish = makeSaluteClass("HOLA"); new Spanish("ALFA").salute("BETA"); // ALFA says "HOLA" to BETA new (makeSaluteClass("HELLO"))("...