Converts the first character of string to upper case with Unicode support
—
Pending
Does it follow best practices?
Impact
Pending
No eval scenarios have been run
Pending
The risk profile of this skill
lodash.upperfirst provides the upperFirst utility function that converts the first character of a string to uppercase while preserving the rest unchanged. It includes sophisticated Unicode handling with support for astral plane characters, combining marks, and zero-width joiners, making it ideal for internationalization and proper text formatting.
npm install lodash.upperfirstvar upperFirst = require('lodash.upperfirst');var upperFirst = require('lodash.upperfirst');
// Basic string capitalization
upperFirst('fred');
// => 'Fred'
// Already uppercase
upperFirst('FRED');
// => 'FRED'
// Empty string
upperFirst('');
// => ''
// Unicode characters
upperFirst('émilie');
// => 'Émilie'
// Works with null/undefined
upperFirst(null);
// => ''
upperFirst(undefined);
// => ''Converts the first character of string to upper case with full Unicode support.
/**
* Converts the first character of `string` to upper case.
*
* @param {string} [string=''] The string to convert.
* @returns {string} Returns the converted string.
*/
function upperFirst(string)Parameters:
string (string, optional): The string to convert. Defaults to empty string if not provided.Returns:
Key Features:
Unicode Examples:
// Emoji with skin tone modifiers - emoji stays unchanged (no uppercase form)
upperFirst('👨🏽💻developer');
// => '👨🏽💻developer' (emoji treated as single character, has no uppercase)
// Complex Unicode sequences
upperFirst('नमस्ते world');
// => 'नमस्ते world'
// Arabic with combining marks
upperFirst('أهلاً');
// => 'أهلاً'
// Accented characters
upperFirst('naïve');
// => 'Naïve'Type Conversion Examples:
// Numbers are converted to strings first
upperFirst(123);
// => '123'
// Booleans are converted to strings first
upperFirst(true);
// => 'True'
// Arrays are converted to strings first
upperFirst([1, 2, 3]);
// => '1,2,3'