Specifically, cases where you want to look really smart and don't care about readability.
"the applicability of reduce() is pretty much limited to associative operators, and in all other cases it's better to write out the accumulation loop explicitly"
artima.com/weblogs/viewpo…
In this case I think the map + join is more expressive. However, I'd go for the loop if the two iterations caused performance issues (which is unlikely).
// Reduce:
arr.reduce((str, item) => str += item, '');
// Not reduce:
arr.map(item => item.foo).join('');
// Loop:
let str = '';
for (const item of arr) str += item.foo;" src="/images/1px.png" data-src="https://pbs.twimg.com/media/ENbkzIJXUAEsaxa.jpg">



![const arr = [1, 2, 3];<br />
<br />
// Reduce:<br />
arr.reduce((total, item) => total + item);<br />
<br />
// Not reduce:<br />
let total = 0;<br />
for (const item of arr) total += item;](https://pbs.twimg.com/media/ENbkyofXkAA391I.jpg)
![const arr = ['one', 'two', 'three'];<br />
// Should be 5<br />
<br />
// Reduce:<br />
arr.reduce((largest, item) => Math.max(largest, item.length), 0);<br />
<br />
// Not reduce:<br />
Math.max(...arr.map(item => item.length));](https://pbs.twimg.com/media/ENbkzztWsAAfbs8.jpg)
![// Array to object keys<br />
const arr = ['hello', 'world'];<br />
// Should become {hello: null, world: null}<br />
<br />
// Reduce:<br />
const obj = arr.reduce((obj, item) => {<br />
obj[item] = null;<br />
return obj;<br />
}, {});<br />
<br />
// Map + fromEntries:<br />
const obj = Object.fromEntries(<br />
arr.map(item => [item, null]),<br />
);<br />
<br />
// Loop:<br />
const obj = {};<br />
for (const item of arr) obj[item] = null;](https://pbs.twimg.com/media/ENbk0UPXUAEciuB.jpg)
![const obj = arr.reduce((obj, item) => ({<br />
...obj,<br />
[item]: null,<br />
}), {});](https://pbs.twimg.com/media/ENbk04vWsAYDNv4.jpg)
