Skip to content

Instantly share code, notes, and snippets.

@cyberfox
Created October 20, 2011 18:43
Show Gist options
  • Save cyberfox/1301931 to your computer and use it in GitHub Desktop.
Save cyberfox/1301931 to your computer and use it in GitHub Desktop.
JavaScript humanize method.
com = { cyberfox: {} };
/**
* Convert a property name into a human readable string by replacing _ with
* spaces, and upcasing the first letter of each word.
*
* @param {string} property The property name to convert into a readable name.
* @return {string} The property name converted to a friendly readable format.
* @private
*/
com.cyberfox.humanize_ = function(property) {
return property.replace(/_/g, ' ')
.replace(/(\w+)/g, function(match) {
return match.charAt(0).toUpperCase() + match.slice(1);
});
};
@jensneeoosh
Copy link

Just helped fix tons of IE8 errors. Thanks!

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