Array
↔ TS Extended Type for Array
CAPITAL Array NOT array
default JS: typeof [] === "object"
List
Array
with sequence of same Type elements & variable length
Tuple
Array
with fixed length & fixed element Type
TS annotate the following array
let colors = ["red", "green", "blue"]
let colors: string[] = ["red", "green", "blue"]
TS annotate the following array
let numbers = [1, 2, 3]
let numbers: number[] = [1, 2, 3]
Add 2 types of Date and string to an array:
const dates_array = [new Date(), "2030-10-10"]
const dates_array: ( Date | string )[] = [new Date(), "2030-10-10"]
const dates_array: (Date | string)[] = [new Date(), "2030-10-10"];