JavaScript convert char to int (Number) | Example code

Use charCodeAt method to convert char to int in JavaScript.

String.charCodeAt(0);

How to convert char to number in JS Example

HTML example code, the first parameter is the index of the string to convert to an ascii code.

<!DOCTYPE html>
<html>
<body>

  <script>

    alert("A".charCodeAt(0);)
  </script>
</body>
</html>

Output:

JavaScript convert char to int Number

Do comment if you have any doubts and suggestions on this JS char int code.

Note: The All JS Examples codes are tested on the Firefox browser and the Chrome browser.

OS: Windows 10

Code: HTML 5 Version


Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.