Languages
[Edit]
EN

TypeScript - get array length

0 points
Created by:
Bess
601

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

Quick solution: 

const array: number[] = [2, 4, 1, 5];

console.log(array.length); // 4

 

Practical example

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

const array: number[] = [10, 20, 30, 40];

for (let i = 0; i < array.length; i++) {
  console.log(array[i]);
}

Output:

10
20
30
40

Alternative titles

  1. TypeScript - how to get array length
  2. TypeScript - 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.
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