Arrays & ReadonlyArray
Learn array basics, the difference between mutable arrays and ReadonlyArray, and how to use typed methods safely.
Intro
Goal: Understand how to declare arrays, use methods with types, and know when to use ReadonlyArray for immutability.
Array declaration
Arrays can be typed with element type syntax (e.g., number[]).
const numbers: number[] = [1, 2, 3];
console.log(numbers[0]);All lessons in this course
- Arrays & ReadonlyArray
- Tuples & labeled tuples
- Enums vs const enum vs union-literal alternatives