How to use charCodeAt() function In Javascript
The charCodeAt() function defined in JavaScript returns the specific Unicode number with a specific index of the string.
Example: To demonstrate printing the ASCII code using the charCodeAt() method in JavaScript.
Javascript
let char1 = "B" ; let asciiValue1 = char1.charCodeAt(0); console.log( "ASCII value of '" + char1 + "': " + asciiValue1); |
Output
ASCII value of 'B': 66
Print ASCII Value of a Character in JavaScript
ASCII is a character encoding standard that has been a foundational element in computing for decades. It is used to define characters in a computer. There is a huge table of ASCII values. To print the values in JavaScript In this post, we print the ASCII code of a specific character. One can print the ASCII code for the specific character in JavaScript using several methods which are as follows:
Table of Content
- Using charCodeAt() function
- Using charPointAt() function
- Finding String ASCII with Array.from() method