Hi Friends 👋,
Welcome to Infinitbility ❤️!
This tutorial is part of the below series.
TypeScript define variable
- How to define type in typescript?
- How to define array in typescript?
- How to define object in typescript?
- How to define array of objects in typescript?
Let start Part 1: How to define type in typescript?
When we start writing code in typescript, so we have to define also type of every variable to hold any value.
like when storing any integer in a variable.
1let num: number = 123;
Now, here we have created the num
variable with the number
data type.
same from string and other data types also…
1let str: string = "shani";2let bool: boolean = true;
Let’s write some variables and check their data type.
1let num: number = 123;2let str: string = "123";3let bool: boolean = true;45typeof num;6typeof str;7typeof bool;
Output

Follow me on Twitter
Join our email list and get notified about new content
No worries, I respect your privacy and I will never abuse your email.
Every week, on Tuesday, you will receive a list of free tutorials I made during the week (I write one every day) and news on other training products I create.