Data Types in TypeScript PART-2

In our previous post we have overview basic about Type Script. Today we will learn about Data Types of Type Script.
Background:
We know that every programming language have basically two data type once is primitive data type and other is costom data type .But today we will discuss about Primitive data type like Boolean, Number, String, Any, Array, Enum
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

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

syntax:

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

Let’s get explaine about data types

 

Boolean:

We can see that above line,Status variable has took  bool type data.if we keep string or number type data in Status variable then will show error.

String:

String is textual data.Double quotes (“) or single quotes(‘) is used in TypeScript. String data type will shown error without double quotes or single quotes.

Number:
Number is very interesting data type in Type Script. Number can take like :
1. Decimal

2. Hexadecimal

3. Binary

4. Octal

Output:
DataTypeOutput

Hope this will be helpful.Happy Coding 🙂

 

One thought on “Data Types in TypeScript PART-2

Leave a Reply

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