Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Javascript convert dash (hyphen) to camelcase
function dashToCamelCase( myStr ) {
return myStr.replace(/-([a-z])/g, function (g) { return g[1].toUpperCase(); });
}
var myStr = dashToCamelCase( 'this-string' );
alert( myStr ); // => thisString
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.