How to find the length of an array in JavaScript?

JavascriptWeb DevelopmentFront End Technology

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 −

Live Demo

<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
raja
Published on 12-Feb-2018 16:45:39
Advertisements