JavaScript charAt() Method

JavaScript charAt() Method returns the character at a specified index or position in a string.

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

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

Output: H

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

Output: l

Video Tutorial

Watch video tutorial on JavaScript charAt() Method.