3 ms·
Personally I don't see this as confusing/problematic. You just need to know .map passes multiple args (which can be extremely useful in other circumstances). E
by daveidol 3y ago
Personally I don't see this as confusing/problematic. You just need to know .map passes multiple args (which can be extremely useful in other circumstances).
Easy fix too: ["1", "2", "3"].map(i => parseInt(i))
- Jtsummers 3y agoWhat's confusing/surprising is that it is different than map in many (most?) other languages with a map implementation. Like in Python it would be: map(some_fun, iterable, *iterables) `some_fun` would have arity 1 or 1 + len(iterables) and be called only with the values of the passed in iterables, not the enumerated indexes or the original iterables or whatever. To get an equivalent, you'd add in an iterable that corresponded to the indexes explicitly. Same thing with Rust with its `enumerate` which would produce a sequence of pairs `(index, original_item)`. And those aren't atypical when examining `map` in other languages.