DEV Community

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

Collapse
 
jefflindholm profile image
Jeff Lindholm

Personally, I would do it like ...(obj && { props: foo}) so it is obvious how the operators work, people who don't immediately know that && has precedence over ...won't read the code as easily.