Skip to content

capitalize

The capitalize() method returns a new string with the first letter uppercased.

Interactive example

Syntax

typescript
function capitalize<
	GenericInput extends string
>(
	input: GenericInput
): Capitalize<GenericInput>

Parameters

  • input: The string to modify. The type is generic (GenericInput extends string) to allow precise literal type inference.

Return value

A new string with the first letter uppercased. The return type is precisely inferred thanks to TypeScript's Capitalize<GenericInput> utility type.

See also

Sources

Released under the MIT license.