Languages
[Edit]
EN

JavaScript - get array length

15 points
Created by:
Paris-Bateman
254

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]);
}

JavaScript - Arrays (popular problems)

Native Advertising
🚀
Get your tech brand or product in front of software developers.
For more information Contact us
Dirask - we help you to
solve coding problems.
Ask question.

❤️💻 🙂

Join