Arrays and Tuples
Arrays use number[] or Array<number>. Tuples fix the length and the type at each position.
Example
const nums: number[] = [1, 2, 3];
const pair: [string, number] = ["age", 30];
console.log(nums, pair[0], pair[1]);Result
[ 1, 2, 3 ] age 30
Exercise
Array of strings.
const a: [] = ["x"];
Quiz Test
These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.