News for hackers. Stuff that matters.
Re:FP techniques that will help you write better JavaScript by dragonwriter on Friday February 11, 2022 @02:37PM (#30306031)
> This problem isn’t about map().

Yes, it is.

Its about .map(), and the broader design of the API around it. Yes, map passes extra args and parseInt takes optional args, and it wouldn’t be a problem if both of those weren’t true. It would be better if .map() was one-arg and had friends .map_with_index(), .map_with_collection(), map_with_index_and_collection().

(It would be better if .map() wasn’t an Array-specific method but part of a general collection protocol that returned [and was applicable to] generators instead of returning Arrays, and then you also had companion methods to like .enumerate(), but that’s…well, farther afield.)

> The normal solution is to write an inline function

Yes, that’s the solution, but that doesn’t say that the design of .map() isn’t a critical component of there being something to solve in the first place.

Re:FP techniques that will help you write better JavaScript by throwawa923423 on Friday February 11, 2022 @06:37PM (#30308342)
I think it is important that you brought awareness to this, this is a really good point and I agree 100%. JavaScript does have hygiene issues with its API design.