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
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"
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


* indicates required
Subscribe to plus2net

    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 All rights reserved worldwide Privacy Policy Disclaimer