upperCase()
upperCase(
str):string
Converts string to upper case with space-separated words.
Parametersโ
str: string | null | undefinedโ
The string to convert.
Returns: stringโ
The upper cased string with words separated by spaces.
See Alsoโ
Sinceโ
2.0.0
Performanceโ
O(n) โ charCode word splitting for short ASCII, regex for long/Unicode/emoji.
Also known asโ
upperCase (Lodash, es-toolkit) ยท โ (Remeda, Radashi, Ramda, Effect, Modern Dash, Antfu)
Exampleโ
upperCase('--Foo-Bar--'); // => 'FOO BAR'
upperCase('fooBar'); // => 'FOO BAR'
upperCase('__foo_bar__'); // => 'FOO BAR'
How it works?โ
Converts string to space-separated uppercase words. Splits on case boundaries, underscores, hyphens, and emojis. Supports Unicode.
Conversion Examplesโ
| Input | Output |
|---|---|
'--Foo-Bar--' | 'FOO BAR' |
'fooBar' | 'FOO BAR' |
'__foo_bar__' | 'FOO BAR' |
Processโ
Use Casesโ
Convert to upper case words ๐โ
Convert string to space-separated uppercase words. Useful for headers, labels, or constants display.
upperCase('fooBar'); // => 'FOO BAR'
upperCase('__foo_bar__'); // => 'FOO BAR'
upperCase('--Foo-Bar--'); // => 'FOO BAR'
Format header textโ
Format identifiers as uppercase display text.
const header = upperCase('contentType');
// => 'CONTENT TYPE'