Skip to content

JavaScript convert char to int (Number) | Example code

  • by

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 or 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

Your email address will not be published. Required fields are marked *