Arrays and Tuples
A typed array works exactly like a JavaScript array, but its type annotation locks in what kind of values it can hold — string[] means an array of strings, and TypeScript will flag anything else that ends up in it.
let fruits: string[] = ["apple", "banana", "cherry"];
console.log(fruits);
console.log(fruits[0]);
fruits.push("date");
console.log(fruits);[ 'apple', 'banana', 'cherry' ] apple [ 'apple', 'banana', 'cherry', 'date' ]
Tuples — fixed length, fixed types, no JavaScript equivalent
A tuple is an array with a fixed length where each position has its own specific type — position 0 might always be a string, position 1 always a number. Plain JavaScript arrays don't have this concept at all; it exists purely in TypeScript's type system.
let point: [number, number] = [3, 4];
console.log(point);
let person: [string, number] = ["Alice", 30];
console.log(`${person[0]} is ${person[1]} years old`);[ 3, 4 ] Alice is 30 years old
At runtime a tuple is just a regular array — the distinction only exists while you're writing the code. Try assigning point[0] a string, and TypeScript stops you before it ever runs.
Next: objects and interfaces — describing the shape of an object, not just a single value.
Practice exercise
Create a tuple pair: [string, number] = ["apples", 3]. Print pair[0] and pair[1] together using a template literal: `${pair[1]} ${pair[0]}`.