// Notice that the method is case-sensitive:
alert( "a".charCodeAt(0) ); // returns 97
alert( "A".charCodeAt(0) ); // returns 65
alert( "\t".charCodeAt(0) ); // returns 9
$str = 'A'; // notice uppercase
echo ord( $str ); // returns 65
echo ord( 'a' ); // returns 97 for lowercase 'a'
Sister method: charAt() returns the character it found at the position index supplied. And fromCharCode() takes Unicode values as arguments, and returns the corresponding string. Between 0 and 128 (mostly latin alphabet), these code points overlap with ASCII encoding.