DEV Community

Discussion on: The shortest way to conditional insert properties into an object literal

Collapse
 
bennypowers profile image
Benny Powers 🇮🇱🇨🇦

I like this pattern not just because it's the "shortest" but because it's the most declarative. This way, I can construct and assign my object in one place, without going back later to mutate it's contents. I think that leads to better code because it reduces the need to mentally execute each line.