Aller au contenu principal

toUpper()

toUpper(str): string

Converts a string to uppercase.

DEPRECATED

Use string.toUpperCase() directly instead.


Parameters

str: string | null | undefined

The string to convert to uppercase.


Returns: string

The string converted to uppercase.


See Also


Since

2.0.0


Also known as

toUpper (Lodash, es-toolkit, Ramda) · toUpperCase (Remeda, Effect) · ❌ (Radashi, Modern Dash, Antfu)


Example

// ❌ Deprecated approach
toUpper('hello world'); // => 'HELLO WORLD'

// ✅ Recommended approach
'hello world'.toUpperCase(); // => 'HELLO WORLD'

How it works?

Converts string to uppercase. Deprecated: Use string.toUpperCase() directly.

Native Equivalent

// ❌ toUpper('hello')
// ✅ 'hello'.toUpperCase()

Use Cases

Convert to uppercase 📌

Convert string to uppercase.

'hello'.toUpperCase();  // 'HELLO'

Format constants

Format text for display.

const header = title.toUpperCase();