0Pricing
TypeScript Academy · Lesson

Tuples & labeled tuples

Learn about tuples: arrays with fixed length and known element types. Discover labeled tuples for readability.

Intro

Goal: Learn how tuples differ from arrays. They have fixed length and element types, and can be labeled for clarity.

Simple tuple

A tuple defines specific element types at each position, unlike arrays where all elements share a type.

let point: [number, number] = [10, 20];
console.log(point[0], point[1]);

All lessons in this course

  1. Arrays & ReadonlyArray
  2. Tuples & labeled tuples
  3. Enums vs const enum vs union-literal alternatives
← Back to TypeScript Academy