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