Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Javascript length property

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 101
    Comment on it

    Javascript length property is used to find out the length of characters or it may returns number of elements in an array
    Every Character gets counted in this property.

    JavaScript Array length Property
    The length property returns the number of elements stored in a particular array.

    < !DOCTYPE html>
    <p>Click the submit button to see result.</p>
    
    <button onclick="myFunction()">submit</button>
    
    <p id="demo"></p>
    
    <script>
    function myFunction() {
        var n = ["Pranav", "Abhishek", "Ayush", "Rajat","Ravi"];
        document.getElementById("demo").innerHTML = n.length;
    }
    </script>
    
    </body>
    </html>
    

    JavaScript String length Property
    The length property returns the string length after counting the characters of that string.

    <p>Click the button to see result.</p>
    
    <button onclick="myFunction()">click</button>
    
    <p id="demo"></p>
    
    <script>
    function myFunction() {
        var str = "Pranav Chhabra";
        var n = str.length;
        document.getElementById("demo").innerHTML = n;
    }
    </script>
    
    </body>
    </html>
    

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: