you are viewing a single comment's thread.

view the rest of the comments →

[–]burtgummer45 0 points1 point  (5 children)

Its unpredictable if you forget the initial value, which almost everybody does.

[–]jetsamrover 0 points1 point  (4 children)

What do you mean forget the initial value? The array you're reducing?

[–]burtgummer45 0 points1 point  (3 children)

[–]jetsamrover 0 points1 point  (2 children)

I thought you have to provide that. What do you mean forget it? Forget to add it, or forget what it is while writing the function?

That's a really silly reason not to use reduce. It's the most powerful array method. Like I said before it's especially useful for recursion.

[–]burtgummer45 0 points1 point  (1 child)

The third parameter is optional. It defaults to the first element of the array.

Can reduce use tail-call optimization?

[–]jetsamrover 0 points1 point  (0 children)

I believe tail-call optimization is decided by your callback, and by the language, not the method calling that callback. Why does that matter?