1.

Explain the various ways to control member visibility in TypeScript.

Answer»

TypeScript provides three KEYWORDS to control the visibility of CLASS members, such as PROPERTIES or methods.

  • public: You can access a public member ANYWHERE outside the class. All class members are public by default. 
  • protected: A protected member is visible only to the subclasses of the class containing that member. Outside code that doesn’t EXTEND the container class can’t access a protected member. 
  • private: A private member is only visible inside the class. No outside code can access the private members of a class.


Discussion

No Comment Found