basarat
TypeScript Deep Dive

Updated 2 days ago

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

a year ago · 2 comments

Closed

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 (http://bit.ly/29AaP6G). The simplicity comes from avoiding the instantiation step.

No description provided.
Basarat Ali Syed @basarat commented a year 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 a year 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
Notifications

You’re not receiving notifications from this thread.


2 participants