re: The shortest way to conditional insert properties into an object literal VIEW POST


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)

Code of Conduct Report abuse