Languages
[Edit]
EN

JavaScript - get array length

15 points
Created by:
Paris-Bateman
504

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

Alternative titles

  1. JavaScript - how to get array length
  2. JavaScript - get array size
Donate to Dirask
Our content is created by volunteers - like Wikipedia. If you think, the things we do are good, donate us. Thanks!
Join to our subscribers to be up to date with content, news and offers.

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