Re: Proposal: Array.prototype.count

2019-01-07 Thread Andrea Giammarchi
[time to write specs, pass through the whole process, ship it to all engines, have it 100% usable without polyfills] [value of this proposal] both sentences represents time, -1 here On Mon, Jan 7, 2019 at 8:35 PM Ranando King wrote: > Either way it goes, there's a lot of ways to do this that

Re: Proposal: Array.prototype.count

2019-01-07 Thread Ranando King
Either way it goes, there's a lot of ways to do this that are all trivial. On Mon, Jan 7, 2019 at 1:31 PM Pier Bover wrote: > If you need to find the length of a filtered array IMO it makes more sense > and is more obvious to just use filter(). > > On Mon, Jan 7, 2019 at 1:12 PM Засим Александр

Re: Proposal: Array.prototype.count

2019-01-07 Thread Pier Bover
If you need to find the length of a filtered array IMO it makes more sense and is more obvious to just use filter(). On Mon, Jan 7, 2019 at 1:12 PM Засим Александр wrote: > Hi everyone. This is proposal for Array.prototype.count (or countOf) > method which allow to count specific elements in an

Re: Proposal: Array.prototype.count

2019-01-07 Thread Jordan Harband
All the iteration methods are a specific case of reduce, in that you can implement them all with reduce. On Mon, Jan 7, 2019 at 11:27 AM Ranando King wrote: > Isn't that just a specific case of Array.prototype.reduce? > > ```js > const evenNumberCount = [1,2,3,4,5].reduce((acc, val) => { !(val

Re: Proposal: Array.prototype.count

2019-01-07 Thread Ranando King
Isn't that just a specific case of Array.prototype.reduce? ```js const evenNumberCount = [1,2,3,4,5].reduce((acc, val) => { !(val % 2) && ++acc; }); ``` On Mon, Jan 7, 2019 at 1:12 PM Засим Александр wrote: > Hi everyone. This is proposal for Array.prototype.count (or countOf) > method which

Proposal: Array.prototype.count

2019-01-07 Thread Засим Александр
Hi everyone. This is proposal for Array.prototype.count (or countOf) method which allow to count specific elements in an array. ```js const evenNumberCount = [1, 2, 3, 4, 5].count(num => num % 2 === 0); ``` Instead of ```js const evenNumberCount = [1, 2, 3, 4, 5].filter(num => num % 2 ===