JavaScript (ES2026) reference · String Methods

JavaScript String charAt() Method

Return the character at a given index as a new string, or an empty string if the index is out of range.

JavaScript (ES2026) Since ES1

Create a free account to save this page, take notes and track your progress. Sign in

Syntax

string.charAt(index)

Parameters

ParameterDescription
index optional Position from 0. Default: 0

Return value

A one-character string, or "".

Examples

Characters by positionTry it yourself
const name = "Ada";
console.log(name.charAt(0), name.charAt(2), JSON.stringify(name.charAt(9)));

Output

A a ""
charAt(), brackets and at()Try it yourself
const s = "hello";
console.log(s.charAt(1), s[1], s.at(1)); // three ways

Output

e e e

Version history

VersionChange
JavaScript ES1Added

Was this page helpful?