Re:The triple dot syntax (` `) in JavaScript: rest vs. spread
by wruza on Sunday May 08, 2022 @06:43PM
(#31308741)
Not sure about the proposed form, but having proper expression-only ifs in arrays and objects would be nice. Including the spread syntax.
[
"foo”,
if (cond1) bar,
if (cond2) ...baz,
]
Pretty sure it was already proposed and rejected, but still.
Re:The triple dot syntax (` `) in JavaScript: rest vs. spread
by archduck on Monday May 09, 2022 @01:43AM
(#31311003)
This ain’t pretty, but it works:
[
“foo”,
...(cond1 ? [bar] : []),
...(cond2 ? baz : []),
]
---Edit: note to self: read the link before commenting.
Re:The triple dot syntax (` `) in JavaScript: rest vs. spread
by somishere on Sunday May 08, 2022 @07:36PM
(#31309024)
Nice one. I run into this regularly, and it always leads to some kind of nullish spread spaghetti. I really like the idea of an empty / non-value operator that works on objects, arguments & iterables.
Q - is it just a matter of liking posts on tc39 discourse to show support?
https://es.discourse.group/t/conditionally-add-elements-to-d...