Re:Why ['1', '7', '11'].map(parseInt) returns [1, NaN, 3] in...
by estebank on Friday June 21, 2019 @02:22PM
(#20245073)
The map function has a bad API surface that interacts poorly with the way people expect it to work. In a better designed API, if you needed the index of each yielded value other languages have some kind of enumerate method that will allow people opt-in to getting the index. Then if you needed the replicate the presented situation you would have something like
I understand that this pattern of having extra "helper" arguments is pervasive in JS and might seem less exotic to the community, but I feel it is a problematic approach, as it is foot-gun prone.
[ Parent
| on HN ]
There are no comments on this comment yet.