JS: charAt() Method

JavaScript programming treat the strings as array and each character of the string has an index.

Suppose we want to know the character at index 1. The JavaScript string class has method called <span style="color:#a30f00" class="tadv-color">charAt()</span> that returns the character at a index from the string.

The <span style="color:#a33100" class="tadv-color">charAt(1) </span>will return a character from string at index location 1.

<!DOCTYPE html>
   <title>JS: charAt() Method</title>
   <meta charset="utf-8">
  var country = "HOLLAND";
//output = 'A'

In the above script, we want to know which character is located at index location 4. The <span style="color:#a30500" class="tadv-color">charAt()</span> method will return ‘A’ from the string.