UNPKG

js-function-lib

Version:

JavaScript function library

21 lines (20 loc) 509 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); /** * 转换字符串string的首字母为大写 * * @param {string} string 要转换的字符串 * @returns {string} 返回转换后的字符串 * @version 1.1.5 * @example * * upperFirst('china'); * // => 'China' * * upperFirst('cHINA'); * // => 'CHINA' */ function upperFirst(string) { return string ? string.replace(string[0], string[0].toUpperCase()) : ''; } exports.default = upperFirst;