How To Use array.length Property Using JavaScript?

Nov 24, 2021 . Admin



Hello Friends,

Now let's see example of how to use array.length property example. We will check how to use array.length property. This is a short guide on use array.length property in javascript. Here you will learn how to use javascript array.length property. Let's get started with how to use array.length property in javascript.

Here i will give you many example how to use array.length property using javascript.

Example : 1
<html>
    <head>
        <title>How To Use array.length Property Using JavaScript? - MyWebtuts.com</title>
    </head>
    <body>
        <h3>How To Use array.length Property Using JavaScript? - MyWebtuts.com</h3>
        <script>
            var arr1 = new Array( 56, 48, 82, 35, 17, 91 );
            document.write(" The elements of array are: " + arr1);
            document.write(" <br>The length of the array is: " + arr1.length);
        </script>
    </body>
</html>  
Output :
The elements of array are: 56,48,82,35,17,91
The length of the array is: 6
Example : 2
<html>
    <head>
        <title>How To Use array.length Property Using JavaScript? - MyWebtuts.com</title>
    </head>
    <body>
    <h3>How To Use array.length Property Using JavaScript? - MyWebtuts.com</h3>
        <script>
            var str = "Welcome to the MyWebtuts.com";
            var arr1 = new Array();
            arr1 = str.split(" ");
            document.write(" The given string is: " + str); 
            document.write("<br><br> Number Of Words: "+ arr1.length);
            document.write("<br><br> Number of characters in the string: " + str.length);
        </script>      
    </body>
</html>  
Output :
The given string is: Welcome to the MyWebtuts.com
Number Of Words: 4
Number of characters in the string: 28

It will help you...

#Javascript