-
-
Save sudhir600/5d998a787082d78ef15c54046e81a05c to your computer and use it in GitHub Desktop.
To convert string to camel case in javascript.
This file contains hidden or 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
function toCamelCase(str) { | |
return str.toLowerCase().replace(/(?:(^.)|(\s+.))/g, function(match) { | |
return match.charAt(match.length-1).toUpperCase(); | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Example
https://jsfiddle.net/sudhir600/8psftvd4/