Navigate back to the homepage

How to define array in typescript?

March 27th, 2022 · 1 min read
keep affilitate

Hi Friends 👋,

Welcome to Infinitbility ❤️!

This tutorial is part of the below series.

TypeScript define variable

  1. How to define type in typescript?
  2. How to define array in typescript?
  3. How to define object in typescript?
  4. 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.

1let 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.

1let numArr: Array<number> = [1, 2, 3];
2let strArr: Array<string> = ["infintbility", "aguidehub"];
3let boolArr: Array<boolean> = [true, false];

Next := How to define object in typescript?

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.

melio affilitate

Looking For React Native Tutorial?

we are trying to create the best Tutorial for react native developers.

When you want a daily updates about React Native Tutorial or infinitbility update subscribe to our newsletter.

Read React Native Tutorial

Request New Tutorial or Article on mail [email protected]

Guide book

Guidebook: The Javascript Monorepo Photoshop Guide



More articles from Infinitbility

How to define type in typescript?

TypeScript, Define data type of data syntax example.

March 26th, 2022 · 1 min read

How to export multiple files in a single file in node js?

Node.js, Learn to export multiple file in one file.

March 25th, 2022 · 1 min read
© 2020–2022 Infinitbility
Link to $ to $ to $ to $ to $ to $mailto:[email protected]