JavaScript array.length | Find Length of an Array

The JavaScript length property is used to find the length of an array. For example:

HTML with JavaScript Code
<!DOCTYPE html>
<html>
<body>

   <p id="xyz"></p>

   <script>
      const cities = ["Tokyo", "Bangkok", "Dubai", "Berlin", "Frankfurt"];
      document.getElementById("xyz").innerHTML = cities.length;
   </script>
   
</body>
</html>
Output

JavaScript length Syntax

The syntax of length property in JavaScript is:

array.length

The array refers to the array whose length we need to find.

Length of an array represents the total number of items or elements available in the array.

JavaScript Online Test


« Previous Tutorial Next Tutorial »