CH API:http://www.css88.com/doc/underscore/
EN API: http://underscorejs.org/#
mixin_.mixin(object)
您可以用您自己的实用程序函数扩展Underscore。传递一个 {name: function}定义的哈希添加到Underscore对象,以及面向对象包装。
_.mixin({
capitalize : function(string) {
return string.charAt(0).toUpperCase() + string.substring(1).toLowerCase();
}
});
_("fabio").capitalize();
=> "Fabio"
本文介绍如何使用mixin方法扩展Underscore.js的功能,并提供了一个字符串首字母大写的实用示例。
8653

被折叠的 条评论
为什么被折叠?



