0Pricing
TypeScript Academy · Lesson

Typed Arrays: T[] and Array<T>

Type arrays and prevent mixing incompatible values.

Welcome

TypeScript lets you type arrays so that only values of a specific type can be stored. This lesson covers the two syntax forms and their use cases.

The T[] Syntax

The most common way to type an array is to append [] to the element type. This is called the shorthand syntax.
const numbers: number[] = [1, 2, 3];
const names: string[] = ['Alice', 'Bob'];
const flags: boolean[] = [true, false, true];

All lessons in this course

  1. Typed Arrays: T[] and Array
  2. Readonly Arrays and Immutable Data
  3. Tuples: Fixed-Length Typed Arrays
  4. Enums: Numeric and String Constants
← Back to TypeScript Academy