News for hackers. Stuff that matters.
Re:Lodash just declared issue bankruptcy and closed every is... by masklinn on Sunday September 17, 2023 @02:41AM (#37542168)
Using reduce to perform a map is a fun way to annoy colleagues.
Re:Lodash just declared issue bankruptcy and closed every is... by 5e92cb50239222b on Sunday September 17, 2023 @03:08AM (#37542309)
Or .map() as a for..of replacement. I always wanted V8/SpiderMonkey developers to make .map()/.reduce() "pure" in the sense of "optimizing away" the expression if its result is not assigned to anything, and see the world burn.
Re:Lodash just declared issue bankruptcy and closed every is... by Zababa on Sunday September 17, 2023 @07:56AM (#37544088)
I think .map() as a for...of replacement makes sense for simple cases. newArray = oldArray.map(el => aFunction(el)) is short, sweet and clean.
Re:Lodash just declared issue bankruptcy and closed every is... by orra on Sunday September 17, 2023 @08:14AM (#37544229)
It's definitely short, but are you doing it for the side effects? Then I find .map() misleading. I'd much prefer a .forEach(), or a for...of.
Re:Lodash just declared issue bankruptcy and closed every is... by masklinn on Sunday September 17, 2023 @08:20AM (#37544275)
If you’re mapping for side effects you deserve a good rap on the head.

The main value of “map” is to denote a 1:1 data transformation. Plus this gets very fraught with many langages mapping lazily, and some not guaranteeing the order of operation.