Optional spreading

TLDR [?...arr] [?...obj]


I see that you show how ...(x || []) and ...(x || {}) are workarounds so the new syntax could be supported by transpilers via that trick.

And I don't see any syntactic ambiguity: the ? is not ambiguous with ternary operator since it must always appear before an ellipsis so after an open bracket or comma, IIRC.

What's the need? What pain do you see from having to use those workarounds?

And these are cleanest examples I have seen so far.

Maybe the pain would be clearer if the explainer included some unclean examples, and showed how, with the proposed, they'd be cleaner.

TLDR [?...arr] [?...obj]

Nit: should the second obj example in the TLDR use curly brackets?

Ooops. Thanks:) You are right

Noted. Will try to clarify and add more examples and provide links to real public code where I see it pattern reapting often

Submitted Optional spreading proposal, since I cannot edit the topic in here