DEV Community

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

Collapse
 
davidsharp profile image
David Sharp

This seems much nicer than my current const obj = { ...{ condition? { prop: value }: {} }}; 🤔

While it's not entirely clear at first glance how it works, I think the intent is clear enough for someone stumbling across it (excusing any bugs caused by gotchas)