Skip to content
Home Tutorials Roadmaps Courses
Log in Join free
Tutorials TypeScript Array Types
TypeScript Intermediate FREE

Array Types

Lesson 1 of 17 Intermediate Interactive

TypeScript supports two array syntaxes: type[] and Array<type>.

Syntax

TYPESCRIPT
let numbers: number[] = [1, 2, 3];
let names: Array<string> = ["Alice", "Bob"];
Array Types
TYPESCRIPT
let numbers: number[] = [1, 2, 3, 4, 5];
let names: Array<string> = ["Alice", "Bob"];

numbers.push(6);
console.log(numbers);

let mixed: (string | number)[] = [1, "two", 3];
console.log(mixed);

let matrix: number[][] = [[1, 2], [3, 4]];
console.log(matrix);

Practice

1
Exercise

Practice this concept.

Answer
Write the code as shown above.

Quick Quiz

1

What did you learn?

This covers the basics.

Interview Questions

It is a fundamental TypeScript feature.