Why embed the JavaScript class in an anonymous function() call?

前端 未结 6 649
北恋
北恋 2021-02-05 10:31

I was reading about the new JavaScript-like language from Microsoft called TypeScript. In the playground (example section), there is a simple class in TypeScript syntax converte

6条回答
  •  梦谈多话
    2021-02-05 10:55

    The anonymous function / self executing closure is usually used to encapsulate scope so that only the returned value is accessible outside of it. (or anything you attach to other objects, like window)

提交回复
热议问题