对于另一种情况,我需要它将第一个字母大写,其余字母小写。以下情况使我更改了此函数: //电子系统5 函数大写(字符串){ return string.charAt(0).toUpperCase()+string.slice(1).toLowerCase(; } 大写(“阿尔弗雷多”)//=>“阿尔弗雷德” 大写(“Alejandro”)//=>“Alejandero 大写(“阿尔贝托”)//=>“阿尔贝多” 大写(“ArMaNdO”)//=>“ArMaNdO” //es6使用破坏 const capitalie=([first,…rest])=>first.toUpperCase()+rest.join(“”).toLowerBase();