Skip to content

Commit 6d87b16

Browse files
authored
Update 字符串变驼峰.js
1 parent ad40cd9 commit 6d87b16

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

字符串变驼峰.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
11
// asd-fgh-jkl ===>asdFghJkl 小驼峰
2+
var toCapitalize = function(str) {
3+
return str.replace(/-\w/g, function(s) {
4+
return s.slice(1).toUpperCase();
5+
});
6+
}
7+
28
function firstUpperCase(str) {
39
return str.toLowerCase().replace(/^\S/g,function(s){return s.toUpperCase();});
410
}

0 commit comments

Comments
 (0)