mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-06 09:47:48 +00:00
Adding _.count to count truthy values in an iterator. _.count([1, 2, 3, 4, 5, 6], function(num){ return num % 2 == 0; }) = 3
This commit is contained in:
23
index.html
23
index.html
@@ -137,12 +137,13 @@
|
||||
<span class="methods"><a href="#each">each</a>, <a href="#map">map</a>,
|
||||
<a href="#reduce">reduce</a>, <a href="#reduceRight">reduceRight</a>,
|
||||
<a href="#detect">detect</a>, <a href="#select">select</a>,
|
||||
<a href="#reject">reject</a>, <a href="#all">all</a>,
|
||||
<a href="#any">any</a>, <a href="#include">include</a>,
|
||||
<a href="#invoke">invoke</a>, <a href="#pluck">pluck</a>,
|
||||
<a href="#max">max</a>, <a href="#min">min</a>,
|
||||
<a href="#sortBy">sortBy</a>, <a href="#sortedIndex">sortedIndex</a>,
|
||||
<a href="#toArray">toArray</a>, <a href="#size">size</a></span>
|
||||
<a href="#reject">reject</a>, <a href="#count">count</a>,
|
||||
<a href="#all">all</a>, <a href="#any">any</a>,
|
||||
<a href="#include">include</a>, <a href="#invoke">invoke</a>,
|
||||
<a href="#pluck">pluck</a>, <a href="#max">max</a>,
|
||||
<a href="#min">min</a>, <a href="#sortBy">sortBy</a>,
|
||||
<a href="#sortedIndex">sortedIndex</a>, <a href="#toArray">toArray</a>,
|
||||
<a href="#size">size</a></span>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
@@ -337,6 +338,16 @@ var evens = _.select([1, 2, 3, 4, 5, 6], function(num){ return num % 2 == 0; });
|
||||
<pre>
|
||||
var odds = _.reject([1, 2, 3, 4, 5, 6], function(num){ return num % 2 == 0; });
|
||||
=> [1, 3, 5]
|
||||
</pre>
|
||||
|
||||
<p id="count">
|
||||
<b class="header">count</b><code>_.count(list, [iterator], [context])</code>
|
||||
<br />
|
||||
Returns a count of elements which pass the truth test (<b>iterator</b>).
|
||||
</p>
|
||||
<pre>
|
||||
var count = _.count([1, 2, 3, 4, 5, 6], function(num){ return num % 2 == 0; });
|
||||
=> 3
|
||||
</pre>
|
||||
|
||||
<p id="all">
|
||||
|
||||
Reference in New Issue
Block a user