capitalize
Capitalizes the first letter of a string.
By default, lowercases the remaining characters.
Pass { lowercaseRest: false } to only uppercase the first character.
Available since v1.9.0
Import
Section titled “Import”Signature
Section titled “Signature”Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
str | string | The string to capitalize |
options | CapitalizeOptions | Options (optional) |
Returns
Section titled “Returns”string — String with first letter uppercased
Examples
Section titled “Examples”Capitalize a word
Section titled “Capitalize a word”Uppercases the first letter and lowercases the rest.
Handle mixed case
Section titled “Handle mixed case”Lowercases all letters except the first one (default behaviour).
Uppercase first only — leave rest untouched
Section titled “Uppercase first only — leave rest untouched”Use { lowercaseRest: false } to preserve the original casing of the remaining characters.
