TypeScript Classes

  • TypeScript have object-oriented programming features like  object,  classes, interfaces, etc.
  • class consist of member variable and member function.

Below is code example:

In above example, whenever  new keyword is used , it invoke the constructor and create new object for Greet.

A constructor is a special function of the class that is responsible for initialising the variables of the class. in above example, it will initialise message with string “hello world”.

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top