Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
123
rated 0 times [  126] [ 3]  / answers: 1 / hits: 139621  / 12 Years ago, mon, june 4, 2012, 12:00:00

Possible Duplicate:

Convert character to ASCII code in Javascript






my requirement is to get the ASCII value of the alphabet letters... Can anyone suggest how to do this in JavaScript?


More From » char

 Answers
14

Here is the example:





var charCode = a.charCodeAt(0);
console.log(charCode);





Or if you have longer strings:





var string = Some string;

for (var i = 0; i < string.length; i++) {
console.log(string.charCodeAt(i));
}





String.charCodeAt(x) method will return ASCII character code at a given position.


[#85168] Saturday, June 2, 2012, 12 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
neildrews

Total Points: 166
Total Questions: 103
Total Answers: 85

Location: Moldova
Member since Sat, Aug 6, 2022
2 Years ago
neildrews questions
Fri, Feb 18, 22, 00:00, 2 Years ago
Tue, Oct 12, 21, 00:00, 3 Years ago
Tue, Mar 23, 21, 00:00, 3 Years ago
Sun, Aug 16, 20, 00:00, 4 Years ago
;