Favorites

JavaScript String.prototype.charAt() Method

☕
Enjoying this site?

Help keep it running with a small coffee donation. Every bit of support is appreciated!

Buy us a coffee
String.prototype.charAt()
JavaScript String Instance methodThis method is supported by all modern browsers.
Updated 28th November 2026

The charAt() method returns the character at a given index of a string, or an empty string if there is none.

Description

The charAt() method returns a new string containing the single UTF-16 code unit at the given index. It doesn't accept negative indexes; use at() for that. Square-bracket access, str[i], does the same thing but returns undefined for missing indexes.

Like at(), it works with UTF-16 code units, so it returns only half of a character for emoji and other characters outside the Basic Multilingual Plane. Use codePointAt() or spread the string into an array when you need whole characters.

Because it returns an empty string rather than undefined for out-of-range indexes, you can safely chain other string methods onto its result, as in the classic capitalize pattern s.charAt(0).toUpperCase() + s.slice(1), which works even when s is empty.

Syntax

string.charAt(index)

Parameters

  • indexThe position of the character, from 0. Defaults to 0.

Return Value

The character at that position, or an empty string if the index is out of range.

Example

const s = 'Hello';
console.log(s.charAt(1));
console.log(s.charAt(10) === '');
console.log(s.charAt(0).toUpperCase() + s.slice(1).toLowerCase());

Browser Support

The following information will show you the current browser support for the String.prototype.charAt() method. Hover over a browser icon to see the version that first introduced support for this method.

This method is supported by all modern browsers.

Desktop

Chrome
Edge
Firefox
Opera
Safari

Tablets & Mobile

Chrome Android
Firefox Android
Opera Android
Safari iOS
Samsung Internet
Android WebView
-
Supported Unknown Not supported
☕
Enjoying this site?

Help keep it running with a small coffee donation. Every bit of support is appreciated!

Buy us a coffee