70

In JavaScript, how to get a string representation of an ASCII value, e.g. how to turn 65 into A?

2
  • 2
    you may mark his answer as correct. There's a little check right below the downvote arrow. Commented Sep 27, 2012 at 10:04
  • See also: [How to convert from Hex to ASCII in javascript?][1] [1]: stackoverflow.com/questions/3745666/… Commented Jun 12, 2013 at 4:07

4 Answers 4

123

The fromCharCode method converts ASCII to a string:

<script type="text/javascript">
document.write(String.fromCharCode(65,66,67)); // ABC
</script>
Sign up to request clarification or add additional context in comments.

1 Comment

See also MDN docs.
10

A reference for those of us that don't like w3schools ;)

Usage:

var myAString = String.fromCharCode(65)

Comments

4

The method you're looking for is String.fromCharCode (http://www.w3schools.com/jsref/jsref_fromCharCode.asp).

Comments

0

charCodeAt() method can be used to get the ASCII value.

2 Comments

The question asks the other way.
however the question asks the other way, it's good to also have this referenced, but a little explanation may fit.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.