-
-
Notifications
You must be signed in to change notification settings - Fork 420
Closed
Labels
Description
Using spread inside a reduce call can turn a O(n) algorithm into O(n**2). See https://www.richsnapp.com/article/2019/06-09-reduce-spread-anti-pattern
Fail
const result = items.reduce((acc, item) => ({
...acc,
[item.name]: item.value,
}, {});Pass
const result = items.reduce((acc, item) => {
acc[item.name] = item.value;
return acc;
}, {})ricealexander