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

前端 未结 6 570
北恋
北恋 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:59

    The closure is the sole mean to call the constructors with parameters:

    var w = new Greeter("hello")
    

    There are other methods but all complicated and with limitations and drawbacks.

提交回复
热议问题