Skip to content

Instantly share code, notes, and snippets.

@ivanstojic
Created November 1, 2009 00:15
Show Gist options
  • Save ivanstojic/223326 to your computer and use it in GitHub Desktop.
Save ivanstojic/223326 to your computer and use it in GitHub Desktop.
String.prototype.toCamelCase = function(major) {
var str = this.toString().replace(/[\-_\s](.)/g, function(m, l) {
return l.toUpperCase();
});
if (major) {
str = str.substr(0, 1).toUpperCase() + str.substr(1);
}
return str;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment