JavaScript at() Method

JavaScript at() Method returns the character at a specific index position of a string.

For example if we have a variable whose value is set to '1234', we can get character at any index position using at() method.

let text = '12345';
let char = text.at(4);
document.getElementById('output').innerHTML = 'Output: ' + char;

Output: 5

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

Output: l

Video Tutorial

Watch video tutorial on JavaScript at() Method.