EN
TypeScript - get array length
0
points
This article will show you how to get array length in TypeScript.
Quick solution:
const array: number[] = [2, 4, 1, 5];
console.log(array.length); // 4
Practical example
The .length property is very often used when iterating over an array.
const array: number[] = [10, 20, 30, 40];
for (let i = 0; i < array.length; i++) {
console.log(array[i]);
}
Output:
10
20
30
40