charAt String JavaScript

The JavaScript string charAt() method retrieves the char value present at the specified index. If n is the size of the string then the index can be from 0 to n-1.

Syntax:

String.charAt(index) 

Parameters:
index: It represents the specified position of a character.

Return:
Char value present at the specified index.

Example 1:

<!DOCTYPE html>
<html>
<body>
<script>
var hello ="HELLO WORLD!";
document.writeln(hello.charAt(11));
</script>
</body>
</html>

Example 2:

<!DOCTYPE html>
<html>
<body>
<script>
var stringObj = 'Best tutorial wesite';
document.write("The character at index 0 is " + stringObj.charAt());
document.write("<br>");
document.write("The character at index 0 is " + stringObj.charAt(0));
document.write("<br>");
document.write("The character at index 1 is " + stringObj.charAt(1));
document.write("<br>");
document.write("The character at index 2 is " + stringObj.charAt(2));
document.write("<br>");
document.write("The character at index 100 is " + stringObj.charAt(100));
</script>
</body>
</html>