Skip to content
Subhajit Sahu edited this page Dec 8, 2022 · 13 revisions

Count values which satisfy a test.

Similar: count, countAs.


function count(x, ft)
// x:  an object
// ft: test function (v, k, x)
const object = require('extra-object');

var x = {a: 1, b: 1, c: 2, d: 2, e: 4};
object.count(x, v => v % 2 === 1);
// → 2

object.count(x, v => v % 2 === 0);
// → 3


References

Clone this wiki locally