Convert char to int using charCodeAt method in JavaScript. Take first char of the string to convert to an ASCII code.
String.charCodeAt(0);
Complete code
<!DOCTYPE html>
<html>
<body>
<script>
alert("A".charCodeAt(0);)
</script>
</body>
</html>
Output:
![JavaScript char to int](https://i0.wp.com/tutorial.eyehunts.com/wp-content/uploads/2021/07/JavaScript-char-to-int.jpg?resize=527%2C181&ssl=1)
Another example
var chr ='A';
chr.charCodeAt(0); //65
Do comment if you have another example or suggestions or doubts on this JS char topic.
Note: The All JS Examples codes are tested on the Firefox browser and the Chrome browser.
OS: Windows 10
Code: HTML 5 Version