What the hell, who on earth thought that behaviour would be a good idea?
In this case, the index of the element (1, 2, 3) is getting passed as the radix with which to parse the element (1, 1, 1).
[1, 2, 3, 4].reduce((x, y) => Math.min(x, y))
should be 1 but [1, 2, 3, 4].reduce(Math.min)
should be NaN, for similar reasons. Unfortunately it's a recurring theme in JS that a lot of useful functions have optional extra parameters and a lot of useful higher order functions pass extra context to their callbacks, causing many traps for the unwary if you try to use these tools in a style that works fine in most functional programming languages."1" of base 0 is 1
"1" of base 1 is NaN
"1" of base 2 is 1
The gotcha here is if you map(fn), you're going to get all three arguments sent to the fn, where map(v => fn(v)) explicitly only sends the first one.
Then again I suppose that you could recreate JavaScripts behaviour even in the fairly strongly typed C# if you wanted to, by defining two overloaded versions of Map as follows:
IEnumerable<B> Map<A,B>(this IEnumerable<B> list, Func<A,B> f)
IEnumerable<B> Map<A,B>(this IEnumerable<B> list, Func<A,int,B> f)
in that case C# would also choose the latter Map when you call it on a function with an optional int argument, similar to what JavaScript would do. However C# will never ignore an optional argument when you're passing around functions, so it's more consistent in that sense. And overloading a function in this way is not the best idea in the first place, it's just that JavaScript kind of encourages it.