Example 1 — Official Capitalize
Mix in a helper, then call it on the OOP wrapper.
_.mixin({
capitalize: function (string) {
return string.charAt(0).toUpperCase()
+ string.substring(1).toLowerCase();
}
});
_("fabio").capitalize();
// → "Fabio" How It Works
- Define the helper.
capitalizeuppercases the first letter. - Mix it in. Underscore copies it to
_and the wrapper. - Wrap a string.
_("fabio")holds the value. - Call the method. Wrapper passes
"fabio"as the first argument →"Fabio".

