An example that shows reduce summing an array of number disguises the true power of this method. You can use reduce to return an new array, an obejct, set, or whatever else you like. All of those are also single values. A single value does not mean solely a primitive type. I would consider adding that clarification so that learners won't be held back by a misconception.
Thank you for your time to respond. Single value doesn't mean to be primitives, but for the simplicity i just used this example. Thanks for pointing out this clyde grey.
Another good use is getting the element from an array that has the highest value of some prop. Since you can get the highest with less comparisons than using sort.
Best bro ! Your video very sample for learn with your created animation !
An example that shows reduce summing an array of number disguises the true power of this method. You can use reduce to return an new array, an obejct, set, or whatever else you like. All of those are also single values. A single value does not mean solely a primitive type. I would consider adding that clarification so that learners won't be held back by a misconception.
Thank you for your time to respond. Single value doesn't mean to be primitives, but for the simplicity i just used this example. Thanks for pointing out this clyde grey.
Another good use is getting the element from an array that has the highest value of some prop.
Since you can get the highest with less comparisons than using sort.
Yes reduce performs faster than sort. Thanks theKWOKA :)
Please explain what recursion is. thanks
Sure Panda Pete :)