Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
To convert string to camel case in javascript.
function toCamelCase(string) {
string = string.toLowerCase().replace(/(?:(^.)|([-_\s]+.))/g, function(match) {
return match.charAt(match.length-1).toUpperCase();
});
return string.charAt(0).toLowerCase() + string.substring(1);
}
@Illizion

This comment has been minimized.

Copy link

@Illizion Illizion commented Nov 30, 2018

this is golden :D Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.