charat(): to get character from a location of a string

<script type="text/javascript">
str='Hello World'
document.writeln(str.charAt(3)); // l
document.writeln("<br>"+str.charAt(4)); // o
document.writeln("<br>"+str.charAt(5)); // Empty space 
document.writeln("<br>"+str.charAt(6)); // W
document.writeln("<br>"+str.charAt(20)); // Empty string
document.writeln("<br>"+str.charAt(-2)); // Empty string
</script>
charAt(): This function takes input number of the location and returns the particular character at that location.

Note that the first character is located at 0th position. Here is an example.
var my_str="Welcome to www.plus2net.com"
document.write(my_str.charAt(3))
The output of above code is c
Learn how to reverse a string by using charat and length property of a string.
JavaScript String Reference Uppercase to lower case by toLowerCase() method
Subscribe to our YouTube Channel here


Subscribe

* indicates required
Subscribe to plus2net

    plus2net.com







    Post your comments , suggestion , error , requirements etc here




    We use cookies to improve your browsing experience. . Learn more
    HTML MySQL PHP JavaScript ASP Photoshop Articles FORUM . Contact us
    ©2000-2024 plus2net.com All rights reserved worldwide Privacy Policy Disclaimer