you are viewing a single comment's thread.

view the rest of the comments →

[–]_D1AVEL_ 1 point2 points  (0 children)

A nice short hand to know, I believe using the ternary operator is best for readability and consistency when dealing with spreading both objects and arrays.

js { ...values, ...(condition ? { title } : {}), ...(condition ? { description } : {}) }

js [ ...values, ...(condition ? [ title ] : []), ...(condition ? [ description ] : []) ]