How to create a string or char from an ASCII value in JavaScript?

前端 未结 3 1342
春和景丽
春和景丽 2020-12-05 16:45

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

相关标签:
3条回答
  • 2020-12-05 17:18

    The fromCharCode method converts ASCII to a string:

    <script type="text/javascript">
    document.write(String.fromCharCode(65,66,67)); // ABC
    </script>
    

    Hope this helps!

    0 讨论(0)
  • 2020-12-05 17:22

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

    0 讨论(0)
  • 2020-12-05 17:45

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

    Usage:

    var myAString = String.fromCharCode(65)

    0 讨论(0)
提交回复
热议问题