Skip to content

charAt ​

The charAt() method returns the character at the specified index in a string.

Interactive example ​

Syntax ​

Classic signature ​

typescript
function charAt(
	input: string,
	index: number
): string

Curried signature ​

typescript
function charAt<
	GenericInput extends string
>(
	index: number
): (input: GenericInput) => string

Parameters ​

  • input: The string from which to retrieve the character.
  • index: The index of the character to return (starts at 0).

Return value ​

A string representing the character at the specified index. If the index is out of bounds, returns an empty string ("").

See also ​

Sources ​

Released under the MIT license.