TypeScript Deep Dive

Updated 3 days ago

Hunan Rostomyan (@hunan-rostomyan) started discussion #21

3 years ago · 2 comments


Since JavaScript (or TypeScript) doesn't have function statics you can achieve the same thing using various abstractions that wrap over a local variable e.g. using a class :

Stateful Functions (Edit this file)

You can achieve the same effect more simply with an IIFE ( The simplicity comes from avoiding the instantiation step.

No description provided.
Basarat Ali Syed @basarat commented 3 years ago

Nice. That is why I used various abstractions. My preference for class is due to the fact that its easy to forget calling () and difficult to review the brackets. The class pattern is less prone to mis typings 🌹

Hunan Rostomyan @hunan-rostomyan commented 3 years ago

Makes sense. I appreciate the feedback. Thanks for the wonderful book, btw. Learned a lot from it.

to join this conversation on GitBook. Already have an account? Sign in to comment

You’re not receiving notifications from this thread.

2 participants