介绍 常用工具 getElementsByClassName $ $A $R Try.these $$ $F $w $H 模块 Enumerable any collect max min include sortBy toArray find select map reject inject size partition entries findAll all detect member zip each grep invoke PeriodicalExecuter Event unload
Collection Functions (Arrays or Objects) _.each(list, iterator, [context]) Alias: forEach Iterates over a list of elements, yielding each in turn to an iterator function. The iterator is bound to the _.map(list, iterator, [context]) Alias: collect P
代码如下: //排序数组 function SortBy(field, reverse, primer) { reverse = (reverse) ? -1 : 1; return function (a, b) { a = a[field]; b = b[field]; if (typeof (primer) != ‘undefined’) { a = primer(a); b = primer(b); } if (a b) return reverse * 1; return 0; }