OneBite.Dev - Coding blog in a bite size

count array's length in Javascript

Code snippet on how to count array's length in Javascript

  const arrayLength = (array) => {
    return array.length;
  };

This code is used to calculate an array’s length. To begin, the const keyword is used to declare a new constant in Javascript. This line is followed by a function named arrayLength. The argument of this function is a single array. To calculate the length of the array, the .length property is used which will return the length as a number. Finally, the value of .length is returned from the function to indicate the number of elements in the array.

javascript