Skip to content

Instantly share code, notes, and snippets.

@ZoolWay
Forked from vjt/camelize.js
Last active May 17, 2016 09:15
Show Gist options
  • Save ZoolWay/f1db0621a2f2875c56bc47224db2a112 to your computer and use it in GitHub Desktop.
Save ZoolWay/f1db0621a2f2875c56bc47224db2a112 to your computer and use it in GitHub Desktop.
String.camelize
// I thought I needed it, but I didn't need it anymore,
// but I already implemented it. So, here we go, if you
// ever would need a Javascript camelize implementation
// you can freely use this :-).
// - vjt@openssl.it Tue Feb 15 16:49:52 CET 2011
jQuery.extend (String.prototype, {
camelize: function () {
return s.replace(/(?:^|[-_])(\w)/g, function (stripped, letter) {
return letter ? letter.toUpperCase () : '';
}).replace(/(^\w)/, function(letter) { return letter.toLowerCase()});
}
});
@ZoolWay
Copy link
Author

ZoolWay commented May 17, 2016

This reviews correctly lowers the very first letter (otherwise we have PascalCase, not camelCase).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment