Re:FP techniques that will help you write better JavaScript
by mnahkies on Friday February 11, 2022 @03:40AM
(#30298813)
The index and the collection iterated over is passed as the 2nd/3rd parameters in JavaScript, so technically you still have access to them, though in the majority of cases people will omit these parameters
[ Parent
| on HN ]
Re:FP techniques that will help you write better JavaScript
by dragonwriter on Friday February 11, 2022 @02:30PM
(#30305963)
> The index and the collection iterated over is passed as the 2nd/3rd parameters in JavaScript,
Yeah, the “map and friends pass extra parameters that are usually ignored” plus the “lots of JS functions optionally take extra parameters that are usually unused” makes it so easy to think of a function as a one-arg function when its really one plus multiple optionals, use it bare in a map, and get stung by it.