find the length of an array in javascript

To find the length of an array in JavaScript, we can use the length property like this:

index.tsx
let myArray = [1, 2, 3, 4, 5];
let arrayLength = myArray.length;
console.log(arrayLength); // Output: 5
104 chars
4 lines

The length property returns an integer representing the number of elements in the array. In the example above, the length of myArray is 5 because there are 5 elements in the array.

gistlibby LogSnag