UNPKG

es-toolkit

Version:

A state-of-the-art, high-performance JavaScript utility library with a small bundle size and strong type annotations.

18 lines (17 loc) 504 B
//#region src/string/upperFirst.ts /** * Converts the first character of string to upper case. * * @param str - The string that is to be changed * @returns The converted string. * * @example * const convertedStr1 = upperFirst('fred') // returns 'Fred' * const convertedStr2 = upperFirst('Fred') // returns 'Fred' * const convertedStr3 = upperFirst('FRED') // returns 'FRED' */ function upperFirst(str) { return str.substring(0, 1).toUpperCase() + str.substring(1); } //#endregion export { upperFirst };