kidoOooOoooOOom

ゲーム開発やってます

今日みかけたunderscore.js

もうこれなしでは生きられないunderscore.js.
今日は filter を使っているのを見かけた。

filter_.filter(list, iterator, [context]) Alias: select

Looks through each value in the list, returning an array of all the values that pass a truth test (iterator). Delegates to the native filter method, if it exists.

var evens = _.filter([1, 2, 3, 4, 5, 6], function(num){ return num % 2 == 0; });
=> [2, 4, 6]