DEV Community

Discussion on: Stop mutating in map, reduce and forEach

Collapse
 
smeijer profile image
Stephan Meijer

You have a bug though 😇

const newItems = items.map(i => ({ ...i, id: userId }))
Enter fullscreen mode Exit fullscreen mode

But yeah, I see where you're coming from, and I do agree that that pattern is often the better one. It was just not the message I was trying to give with this article. You might be interested in reading dev.to/smeijer/don-t-stop-mutating... as well.

Thanks for sharing though. Appreciated 🙂