_.capitalize([string=‘’])

_.capitalize() 方法将字符串的第一个字符转换为大写,其余字符转换为小写。

参数

  • string (string): 要转换的字符串。

返回值

(string): 返回转换后的字符串。

示例

const result = _.capitalize("hello world");
console.log(result);
// => 'Hello world'

在这个示例中,字符串 'hello world' 被转换为了 'Hello world'