Skip to main content

Function: capitalize()

capitalize(str, options?): string

Defined in: string/case/index.ts:142

Capitalizes the first character of a string.

Parameters

str

string

The string to capitalize

options?

CaseOptions

Case conversion options

Returns

string

The string with first character capitalized

Example

capitalize('hello world')
// => 'Hello world'

capitalize('HELLO')
// => 'HELLO' (only capitalizes first char, doesn't lowercase rest)

capitalize('')
// => ''

See

titleCase - to capitalize all words