Enum in TypeScript PART-3

In our previous post we have overview datatype in Type Script. Today we will learn about enum of Type Script.

Background:

Enum is helpful addition to the standard set of datatypes from JavaScript. data is stored in enum.
Enum’s data do not modify without enum block. Enums begin numbering their members starting at 0, By default. but it may be changed by manually.

You can always download the source code here.

dicon Sourc Code

Now we will Create a simple application.
Let’s get started:  
Create a new project with Visual Studio 2015 > File > New > Project

Untitled

Once click ok button, a project with need typescript’s reference  will be created .

Create ts file:
Right click on your project >>click add>>click Javascript File and give named “SalaryCal.ts” and once click ok Button.Bellow is the following code

Let’s get explain about enum:

Above we can see that we have declared enum which name is “SalaryHead” . There are assigned some enum’s property. When it needs to use in our application then just call enum. But enum’s property never change without enum scope. Now if enum’s property is called then we get assigned value.

Output:

Enumoutput
 

Above is Status enum which is contained three status like IsDelete, IsPending and IsApprove.
Call:
Status[0]
Output:
IsDelete
Hope this will be helpful.Happy Coding ?

Leave a Reply

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