- 
                Notifications
    
You must be signed in to change notification settings  - Fork 5
 
count
        Subhajit Sahu edited this page Mar 17, 2020 
        ·
        30 revisions
      
    Counts occurrences of a value.
array.count(x, v, [fn]);
// x:  an array
// v:  value
// fn: compare function (a, b)
// --> occurrencesconst array = require('extra-array');
var x = [1, 1, 2, 2, 4];
array.count(x, 2);
// 2           ^  ^
var x = [1, 1, 2, 2, 4];
array.count(x, 3, (a, b) => a < b? 0:1);
// 4     ^  ^  ^  ^