JavaScript charCodeAt() Method

JavaScript charCodeAt() Method returns the unicode of character at the given index position in a string.

For example if we have a variable named text whose value is set to HowToCodeSchool. We can use JavaScript charCodeAt() Method to find out the unicode of character present at any position of string.

let text = 'HowToCodeSchool';
let code = text.charCodeAt(0);
document.getElementById('output').innerHTML = 'Output: ' + code;

Output: 72

let text = 'HowToCodeSchool';
let code = text.charCodeAt(14);
document.getElementById('output').innerHTML = 'Output: ' + code;

Output: l08

Video Tutorial

Watch video tutorial on JavaScript charCodeAt() Method.