loading...

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

FULL DISCUSSION
 

Basically, it evaluates like this:
...(condition && { prop: value }),

 

Very helpful what Stan posted here. Parenthesis really help. Actually they are a default lint recommendation in this specific case. I think adding them to the code in the article would help a lot.

 

But it wouldn't be the shortest anymore ;)

hey man! I'm trying to help you here! lol...great article!

Code of Conduct Report abuse