What is the JavaScript equivalents for Chr() and Asc()

Posted by SteveHardie | On: Sep 18 2009

Use:  String.fromCharCode(charCode)


var str1=String.fromCharCode(65)

will return “A”

charCodeAt(index) returns the char code for the character at a given
index position within a string (zero based index).

So if you want the char code for a single character:-

var nCharCode="A".charCodeAt(0);

will return 65

See a list of Character Codes Here

Leave a comment