Created
July 10, 2014 06:25
-
-
Save hehongwei44/7e879f795226316c260d to your computer and use it in GitHub Desktop.
将单个字符串的首字母大写
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* | |
* 将单个字符串的首字母大写 | |
* | |
*/ | |
var fistLetterUpper = function(str) { | |
return str.charAt(0).toUpperCase()+str.slice(1); | |
}; | |
console.log(fistLetterUpper('hello')); //Hello | |
console.log(fistLetterUpper('good')); //Good |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment