Skip to content

Instantly share code, notes, and snippets.

@kingcody
Last active December 25, 2015 22:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kingcody/7051372 to your computer and use it in GitHub Desktop.
Save kingcody/7051372 to your computer and use it in GitHub Desktop.
extend js string object to include toCamelCase method
// string.toCamelCase()
if (!String.prototype.toCamelCase) {
String.prototype.toCamelCase = function toCamelCase() {
return this.toLowerCase().replace(/(\-[a-zA-Z])/g, function($1) {
return $1.toUpperCase().replace('-','');
})
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment