Standard built-ins

String.prototype.at()

Try the free JavaScript compiler

Reads a UTF-16 unit at a relative index; a negative index counts from length. Out of bounds returns undefined.

Formal Syntax & Structure

javascript syntaxjavascript
text.at(index)

Parameters & Attributes

NameTypeDescription
indexNumberIndex converted to an integer.

Return Value

String | undefined

One code unit or undefined.

Working Example

Example Snippetjavascript
console.log("abc".at(-1));
JavaScript Reference