[ “foo”, ...(cond1 ? [bar] : []), ...(cond2 ? baz : []), ]
Edit: note to self: read the link before commenting.