Underscore.JS-コレクションの処理
Underscore.JSには、コレクションの処理に役立つ多くの使いやすいメソッドがあります。この章では、それらについて詳しく説明します。
Underscore.JSは、以下に示すようにコレクションを処理するためのさまざまなメソッドを提供します-
| シニア番号 | メソッドと構文 |
|---|---|
| 1 | 含まれています _.contains(list、value、[fromIndex]) |
| 2 | 呼び出す _.invoke(list、methodName、* arguments) |
| 3 | 摘む _.pluck(list、propertyName) |
| 4 | 最大 _.max(list、[iteratee]、[context]) |
| 5 | 分 _.min(list、[iteratee]、[context]) |
| 6 | 並び替え _.sortBy(list、iteratee、[context]) |
| 7 | groupBy _.groupBy(list、iteratee、[context]) |
| 8 | indexBy _.indexBy(list、iteratee、[context]) |
| 9 | countBy _.countBy(list、iteratee、[context]) |
| 10 | シャッフル _.shuffle(list) |
| 11 | サンプル _.sample(list、[n]) |
| 12 | toArray _.toArray(list) |
| 13 | サイズ _.size(list) |
| 14 | パーティション _.partition(list、predicate) |
| 15 | コンパクト _.compact(list) |