charAt

Returns the character at the specified index (position)

Syntax

charAt(pos)

Returns

returns (string) get a single char from string

Parameters

pos (integer)
position

Usage

for( var i = 0; i < test.length; i++ )
{
    echo( i + ": " + test.charAt(i) );
}

/* this will output:
0: t
1: e
2: s
3: t
4:  
5: v
6: a
7: l
8: u
9: e
*/

Example usage of this funtion is for checking allowed characters in a string:

function allowedCharacters(v)
{
   var allowed = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890-_()+ ";
   for ( var i=0; i < v.length; i++ )
   {
      if( allowed.indexOf( v.charAt(i) ) == "-1" )
      {
         return false;
      }
   }
   return true ;
}