Skip to content
Subhajit Sahu edited this page Jun 11, 2020 · 13 revisions

Counts values which satisfy a test. 🏃 📼 📦 🌔 📒

Alternatives: count, countAs.

object.count(x, fn, [ths]);
// x:   an object
// fn:  test function (v, k, x)
// ths: this argument
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