Private parameters in Typescript

后端 未结 3 908
忘了有多久
忘了有多久 2020-12-31 02:17

I am learning Angular2 and working with classes in javascript first time.

What does the private parameter and why

3条回答
  •  伪装坚强ぢ
    2020-12-31 03:20

    private will scope this variable for this class (function). public will allow access from outside, if you have the instance of this class. protected is important for properties inside a abstract super class. As i started with Typescript, playground on the TypeScript page (https://www.typescriptlang.org/play/index.html) helped me to understand what really happend. Keep in mind, that TypeScript is sugar for your JavaScript

提交回复
热议问题