Languages
[Edit]
EN

JavaScript - how to get array length

0 points
Created by:
Dirask Admin - Marvin
1820

This article will show you how to get array length in JavaScript.

Quick solution: 

// ONLINE-RUNNER:browser;

const numbers = [2, 4, 1, 5];
console.log( numbers.length ); // 4

 

Practical example

The .length property is very often used when iterating over an array.

// ONLINE-RUNNER:browser;

const myArray = [10, 20, 30, 40];
for (let i = 0; i < myArray.length; i++) {
    console.log(myArray[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