DEV Community

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

Collapse
 
chasm profile image
Charles F. Munat

This is referred to as the "either/or fallacy", also referred to as the "false dilemma": en.wikipedia.org/wiki/False_dilemma

This is a perfectly self-explanatory technique. If you understand the spread syntax, and how short-circuted Boolean expressions work, then you can see at a glance what this does. The text above is not an explanation of the code, but proof that it works without surprises. Hence, this is both the shortest and quite self-explanatory.

I would even go so far as to say that this is a lot more readable than the alternatives. Bravo, Mr. Costa.

At no point does the author claim that short code should supersede readable code.

Collapse
 
jfet97 profile image
Andrea Simone Costa • Edited

You centered the point, thank you for intervening!

P.S. I think it's very readable too, but I'm realizing, reading a great number of opinions and comments even on a small thing like the one I presented in the article, how readability is a subjective thing.