Get Array Length in JavaScript
In JavaScript, Array.length property returns the number of elements present in the array.
Syntax
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);