+
81
-

js将字符串首字母大写怎么写?

js将字符串首字母大写怎么写?

网友回复

+
1
-

写法一: let name = 'hello' name.charAt(0).toUpperCase() + name.slice(1) 写法二: let name = 'hello' name.slice(0, 1).toUpperCase() + name.slice(1) 写法三: let name = 'hello' name.substring(0, 1).toUpperCase() + name.substring(1)

我知道答案,我要回答