Arrays store multiple values of the same type.
Example:
let numbers: number[] = [1, 2, 3, 4];
let colors: string[] = ["red", "green", "blue"];Key Points:
- Arrays can be declared with the
[]syntax. - You can also use
Array<type>to define an array type.
Example with Array<type>:
let fruits: Array<string> = ["apple", "banana", "orange"];Accessing Array Elements:
let firstNumber: number = numbers[0]; // 1
let firstColor: string = colors[0]; // "red"