What is the "context" parameter in reduce()
Can someone explain with an example the reduce( function, initial, list, context ) function's "context " parameter. I didn't find an example for it in the docs.
Can someone explain with an example the reduce( function, initial, list, context ) function's "context " parameter. I didn't find an example for it in the docs.
Hi there,
I tried implementing various cases of it below for my understanding. 
If we examine the pattern below, it looks like the context is being passed in every evaluation as an extra value along with the initial and respective item from the list.
Ex. In the expression on line 4, you can see that the result has been increased by 3. This means that the value in 'context' was passed in the function along with the other 2 values, every time the reduce did an iteration. You can find a similar pattern in other expressions written in the above image.
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.