StackOverflow - StackOverflow
Reduce with deconstruction or forEach - Iteration and Airbnb JavaScript Style Guide
You can use Object.assign
, which doesn't create a new object, but rather just appends the item to the accumulator. Would be better for performance and adheres to the style guide.
Object.keys(things)
.reduce((acc, thing) => Object.assign(acc, {[thing]: 'blue' }), {})
Was this helpful?
Related Articles
Have a different question?
Can't find the answer you're looking for? Submit your own question to our community.
🛎️ Get Weekly OTA Fixes
New answers, vendor issues, and updates — straight to your inbox.