Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • JavaScript String charAt() Method

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 129
    Comment on it

    JavaScript String charAt() Method
    This method is used whenever we want to Return the first character of a string
    for example:
    var str = "PRANAV CHHABRA";
    var v = str.charAt(0);

    Result:
    P

    Now below is the full example to illustrate charAt() method:

    <!DOCTYPE html>
    <html>
    <body>
    
    <p>Click the result button to display the first character of the string "PRANAV CHHABRA".</p>
    
    <button onclick="myFunction()">Result</button>
    
    <p id="abc"></p>
    
    <script>
    function myFunction() {
        var str = "PRANAV CHHABRA";
        var v = str.charAt(0)
        document.getElementById("abc").innerHTML = v;
    }
    </script>
    
    </body>
    </html>
    

    OUTPUT
    P

 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: