Typescript – Classes – Constructors

Classes and constructors are the bread and butter for any object oriented programming language. Following is the code sample on how to create classes and constructors in typescript. Class keyword is used to create a class.

Following creates a new object of type Rectangle.

Typescript – Constructors

The above code can be also done using a constructor, following is how you would create a typescript constructor. the keyword to use here is constructor .

Feel free to play around with typescript using the playground .

Leave a Reply

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