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 2: How to define array in typescript?
Here, we will learn to create an array in typescript, due to the static typing feature we have to define the data type of the array before assigning value.
So, when we going to create an array we should know which data type we will store in array…
like when we have to create array of numbers.
we will write like below.
let arr: Array<number> = [1, 2, 3];
Here we are using
Array<number> to know it’s a array of numbers same like others array of data type.
let numArr: Array<number> = [1, 2, 3]; let strArr: Array<string> = ["infintbility", "aguidehub"]; let boolArr: Array<boolean> = [true, false];