Re:Javascript Arrays and Functional Programming
by bestest on Thursday August 03, 2017 @10:11AM
(#14919711)
That's the thing about functional programming. I personally don't remember the last time I had the need to write a foreach loop. Foreach loops even kind of feel _dirty_ to me.
All I really need now is Array.map, Array.reduce, Array.filter, Array.sort, Object.keys, Object.values.
Reduce is very powerful, you just have to get to know it.
All I really need now is Array.map, Array.reduce, Array.filter, Array.sort, Object.keys, Object.values.
Reduce is very powerful, you just have to get to know it.
Edit: this is how I'd use reduce in this case — https://news.ycombinator.com/item?id=14919636 — talk about line numbers