charAt()

ES3+

Returns the character at the specified index in a string.

Syntax

string.charAt(index)

Parameters

index number

The index of the character to return

Return Value

string

The character at the specified index

Examples

JavaScript
const str = 'Hello';
console.log(str.charAt(0));
console.log(str.charAt(4));
Output:
// 'H' 'o'

Related Methods