JavaScript Code

JavaScript Array length


length – Get Array Length

array.length
  • array is an array of elements
  • length is the array property name

length property returns the number of elements in the array

Examples

1. get length of the array numbers

let numbers = [4, 1, 7, 3, 2];
let output = numbers.length;
console.log('Array length : ' + output);

2. length of an empty array

let numbers = [];
let output = numbers.length;
console.log('Array length : ' + output);


Copyright @2022