JavaScript (ES2026) reference · String Methods

JavaScript String codePointAt() Method

Return the full Unicode code point at an index, correctly handling emoji and other characters outside the BMP.

JavaScript (ES2026) Since ES2015

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

Syntax

string.codePointAt(index)

Parameters

ParameterDescription
index Position (in UTF-16 code units).

Return value

A number, or undefined.

Examples

An emoji's code pointTry it yourself
console.log("\u{1F42B}".codePointAt(0).toString(16));

Output

1f42b
Loop with for…of to get whole charactersTry it yourself
for (const ch of "a\u{1F600}") {
  console.log(ch.length, ch.codePointAt(0)); // each item is a whole character
}

Output

1 97
2 128512

Version history

VersionChange
JavaScript ES2015Added

In other languages

Was this page helpful?