In ES6 you can use spread operator. One string solution:

Copy Math.min(...items)
Answer from Sergey Zhukov on Stack Overflow
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Global_Objects › Array › reduce
Array.prototype.reduce() - JavaScript | MDN
Therefore, if your accumulator is an array or an object and you are copying the array or object on each iteration, you may accidentally introduce quadratic complexity into your code, causing performance to quickly degrade on large data. This has happened in real-world code — see for example Making Tanstack Table 1000x faster with a 1 line change. Some of the acceptable use cases of reduce() are given above (most notably, summing an array, promise sequencing, and function piping).
🌐
W3Schools
w3schools.com › jsref › jsref_reduce.asp
JavaScript Array reduce() Method
HTML Reference CSS Reference JavaScript Reference SQL Reference Python Reference W3.CSS Reference Bootstrap Reference PHP Reference HTML Colors Java Reference AngularJS Reference jQuery Reference · HTML Examples CSS Examples JavaScript Examples How To Examples SQL Examples Python Examples W3.CSS Examples Bootstrap Examples PHP Examples Java Examples XML Examples jQuery Examples
Discussions

javascript - Using reduce() to find min and max values? - Stack Overflow
I have this code for a class where I'm supposed to use the reduce() method to find the min and max values in an array. However, we are required to use only a single call to reduce. The return array More on stackoverflow.com
🌐 stackoverflow.com
javascript - How do I write my own `reduce` function? - Stack Overflow
Communities for your favorite technologies. Explore all Collectives · Stack Overflow for Teams is now called Stack Internal. Bring the best of human thought and AI automation together at your work More on stackoverflow.com
🌐 stackoverflow.com
Animal advocates should be cautious of cost-effectiveness — EA Forum
It's easy to apply cost-effectiveness without nuance, which can lead down the wrong path. More on forum.effectivealtruism.org
🌐 forum.effectivealtruism.org
February 26, 2026
Mastering the reduce function

Hey so I wrote this article and 100% transparency - I'm a new writer. I do a lot of front-end work and I'm just trying to post relevant content. I had trouble when I started learning the functional methods within Array.prototype. I thought this would be useful to this sub. This seems to fit the subreddit's guidelines and it was downvoted into oblivion.

If you downvoted, and don't mind sharing, could you tell me why? I just want to get better, and I'm sort of scratching my head here trying to figure out what went wrong. I had quite a few friends review this article (work friends as well as in JS/front-end communities) before I posted it, and the sentiment was generally positive.

More on reddit.com
🌐 r/javascript
8
0
July 19, 2018
🌐
Reddit
reddit.com › r/learnjavascript › can anyone explain to me easily .reduce in js !
r/learnjavascript on Reddit: Can anyone explain to me easily .reduce in js !
August 2, 2022 -

I own searched online but I do not understand‏‏‎‏‏‎‏‏‎‏‏‎­things like accumalator or reducer, I understand .map and .filter but not .reduce. If you could an analogy would be appreciated.

Top answer
1 of 5
17
Reduce is the most low-level of these array iteration methods, so it has the widest variety of potential uses and requires the most complex boiler plate to write. That makes it hard to sum up in a concise way. You often hear people describe reduce as "reducing an array to a single value" or something like that, but I find that definition both hard to understand and kind of inaccurate (reduce can produce another array!). So I don't really try to sum up reduce. I just think of it purely in mechanical terms. Imagine we wrote our own version. function reduce(items, iteratee, initial) { let accumulator = initial; for (const item of items) { accumulator = iteratee(accumulator, item); } return accumulator; } We can then use this reduce just like the built in one. function add(x, y) { return x + y; } const nums = [1, 2, 3]; const sum = reduce(nums, add, 0); console.log(sum); // 6 So what does reduce do? It calls a function on each item in an array, passing along both the result of the previous call and the item itself, before finally returning the result of the final call. It defies any less mechanical definition because it is a fiddly mechanical function with only fiddly technical use cases. EDIT: clarified wording
2 of 5
3
you use .map() to create a new array of the same length as the input array you use .filter() to create a new array containing a subset of the input array you use .reduce() to create something entirely new using an array as an input For example, if we have const lovers = ["mindy", "jed", "jerry"]; const sentence = lovers.reduce((phrase, name) => `${name} loves ${phrase}`); console.log(sentence); // jerry loves jed loves mindy We have transformed an array into a string! I just pulled this monkey-island-esque example out my ass, but you get the gist; use .reduce() when you wanna take an array of things, and generate something entirely new using them.
🌐
The Code Barbarian
thecodebarbarian.com › javascript-reduce-in-5-examples.html
Understand JavaScript Reduce With 5 Examples | www.thecodebarbarian.com
April 28, 2020 - Here's 5 examples to help you understand how to use `Array#reduce()` in JavaScript, including 4 common use cases and one not-so-common use case.
🌐
freeCodeCamp
freecodecamp.org › news › javascript-reduce-method-code-examples
How JavaScript's Reduce Method Works – Explained with Code Examples
February 19, 2024 - Introduced alongside other array methods in ECMAScript 5, reduce() offers a unique and powerful way to transform arrays into single values. In this article, you'll learn about the reduce() method by understanding what it is, its syntax, and finally ...
Find elsewhere
🌐
Medium
medium.com › @lwkchan › javascripts-array-reduce-method-a-guide-and-a-commendation-on-its-flexibility-ea5dc192fad5
JavaScript’s Array reduce() method: a guide and a commendation on its flexibility | by Laura Chan | Medium
May 17, 2018 - Then, as we actually reduce the sauce by simmering it over low heat, it thickens and reduces in size; we reduce the elements of the array by applying each one to the callback method. What results in both cases is one product: a bolognese sauce and a JavaScript Object. The above examples show that the reduce() method callback takes two parameters: the accumulator, which accumulates the return value of each callback; and the value, which represents the current element being processed.
🌐
GeeksforGeeks
geeksforgeeks.org › javascript › javascript-array-reduce-method
JavaScript Array reduce() Method - GeeksforGeeks
... const a = [2, 4, 6]; function sum2(acc, x) { return acc + x; } const sum = a.reduce(sum2, 0); console.log(sum); ... The JavaScript array reduce method returns a single value/element after traversing the complete array.
Published   July 11, 2025
🌐
DEV Community
dev.to › sanspanic › the-javascript-reduce-method-3j8l
The JavaScript Reduce Method - DEV Community
July 23, 2021 - Javascript comes with a bunch of inbuilt array methods designed to make our lives easier. They provide out-of-the-box, frequently needed functionality for iterating through or manipulating arrays in specific ways. There's quite a few of them and whilst it's completely unnecessary to remember them all, it's a good idea to have some solid intuitions about what can be achieved using them. According to MDN, the reduce() method executes a callback function (that you provide) on each element of the array, resulting in a single output value.
🌐
TutorialsPoint
tutorialspoint.com › javascript › javascript_reduce_method.htm
JavaScript - Reduce Method
In the following example, we are using the JavaScript TypedArray reduce() method to execute the user-provided function named multi() on each element of this typed array [1, 2, 3, 4, 5]. The multi() function multiplies all the elements within ...
🌐
React
legacy.reactjs.org › docs › optimizing-performance.html
Optimizing Performance – React
You can also rewrite code that mutates objects to avoid mutation, in a similar way. For example, let’s say we have an object named colormap and we want to write a function that changes colormap.right to be 'blue'. We could write:
🌐
Envato Tuts+
code.tutsplus.com › home › coding fundamentals
5 Real-Life Uses for the JavaScript reduce() Method | Envato Tuts+
November 28, 2021 - Another simple use for JavaScript reduce() is to obtain the number of times each item appears inside an array collection. For example, here is the code for getting the total number of occurrences for each fruit in an array of fruits:
🌐
CDC
cdc.gov › respiratory-viruses › prevention › precautions-when-sick.html
Preventing Spread of Respiratory Viruses When You're Sick | Respiratory Illnesses | CDC
May 12, 2026 - Using precautions for the next 5 days can help reduce this risk. After this 5-day period, you are typically much less likely to be contagious. However, some people, especially people with weakened immune systems, can continue to spread the virus for a longer period of time.
🌐
Tabnine
tabnine.com › home › how to use array reduce method in javascript
How to Use Array reduce method in JavaScript - Tabnine
October 20, 2024 - In such a case, the reducer callback function is not executed for the first item. The index count begins at one, instead of the usual zero. When omitting an initialValue, the result would be the same as if the first iteration was skipped. In the above example, the array being operated on was an array of numbers describing sales totals.
🌐
LessWrong
lesswrong.com › posts › hMBZHXA6vjj8xhCfw › storing-food
Storing Food
February 22, 2026 - Aside from the tail-risk reduction, there are also day-to-day benefits of having more food on hand. We can go to the grocery store less often, buy a larger proportion of our food when it's on sale, go to the farther store that charges less, and cook more things without going to the store.
🌐
Medium
medium.com › swlh › ways-to-use-the-reduce-method-in-javascript-f3d0f309c9e0
Ways to Use the Reduce Method in Javascript | by Cathy D'Onofrio | The Startup | Medium
January 13, 2021 - I hope that these breakdowns and examples help you understand how reduce works and how to implement it beyond summing up values! ... https://medium.com/@vmarchesin/using-array-prototype-reduce-in-objects-using-javascript-dfcdae538fc8
🌐
Medium
medium.com › @AlexanderObregon › mastering-the-javascript-reduce-function-a-comprehensive-guide-c26934ad4218
Mastering the JavaScript reduce() function | Medium
April 23, 2024 - Learn how to use the JavaScript reduce() function to condense an array into a single value. Practical examples and tips included.
🌐
Effective Altruism Forum
forum.effectivealtruism.org › posts › zQfCdoGcFYzzThrwd › animal-advocates-should-be-cautious-of-cost-effectiveness
Animal advocates should be cautious of cost-effectiveness — EA Forum
February 26, 2026 - Likewise, if we're optimising for the reduction of near-term animal suffering, then we can compare welfare improvement projects using a standardised measure of suffering like Ambitious Impact's "Suffering-Adjusted Days" (SADs) and invest in the ones which reduce the most SADs per dollar.
🌐
Simplilearn
simplilearn.com › home › resources › software development › javascript tutorial: learn javascript from scratch › javascript array reduce(): explained with syntax and examples
JavaScript Array Reduce(): Explained With Syntax and Examples | Simplilearn
July 16, 2024 - Learn everything about JavaScript array reduce and how you can use this method to reduce an array to a single value. Explained with syntax and examples.
Address   5851 Legacy Circle, 6th Floor, Plano, TX 75024 United States