![]() |
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() functionThe 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
Output
ASCII value of 'B': 66 Using charPointAt() functionThe charPointAt() function also returns the unicode of the string. It returns the specific Unicode number with a specific index of the string. Example: To demonstrate printing one ASCII character from the string using the charPointAt() function in JavaScript. Javascript
Output
ASCII Number = 101 Using Array.from() methodTo find the full string ascii values using the charPointAt() method along with Array.from() method. First we convert string into the array using the Array.from() method then convert each array element into the ASCII value. Example: To demonstrate printing the whole string ascii values using the Array.from() method. Javascript
Output
ASCII values of characters in 'GeeksforGeeks': 71, 101, 101, 107, 115, 102, 111, 114, 71, 101, 101, 107, 115 |
Reffered: https://www.geeksforgeeks.org
JavaScript |
Type: | Geek |
Category: | Coding |
Sub Category: | Tutorial |
Uploaded by: | Admin |
Views: | 15 |