Javascript - How to access each character of a string

By xngo on June 17, 2019

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "">
    <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
    <script type="text/javascript">
       * Example showing how to access each character of a string using the charAt() function.
      var sVeryLongString = "Hello, world!";
      var sEachCharacters = "";
      for(i=0; i<sVeryLongString.length; i++)
        sEachCharacters += sVeryLongString.charAt(i)+"\n";
    <title>Access each charater of a string</title>


About the author

Xuan Ngo is the founder of He currently lives in Montreal, Canada. He loves to write about programming and open source subjects.