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