Computer >> Computer tutorials >  >> Programming >> Javascript

How to find the length of an array in JavaScript?


To find the length of an array, use the JavaScript length property. JavaScript array length property returns an unsigned, 32-bit integer that specifies the number of elements in an array.

Example

You can try to run the following code to find the length of an array −

<html>
   <head>
      <title>JavaScript Array length Property</title>
   </head>
   <body>
      <script>
         var arr = new Array( 50, 60, 70, 80 );
         document.write("arr.length is : " + arr.length);
      </script>
   </body>
</html>

Output

arr.length is : 4