# Optional spreading

**URL:** <https://es.discourse.group/t/optional-spreading/93>\
**Category:** 💡 Ideas\
**Tags:** proposal\
**Created:** [August 23, 2019, 12:26am UTC](https://es.discourse.group/t/optional-spreading/93 "2019-08-23T00:26:56Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![askbeka](https://yyz2.discourse-cdn.com/free1/user_avatar/es.discourse.group/askbeka/32/119_2.png) [@askbeka](https://es.discourse.group/u/askbeka)\
**Post date:** [August 23, 2019, 12:26am UTC](https://es.discourse.group/t/optional-spreading/93/1 "2019-08-23T00:26:57Z")

</div>

**TLDR** `[?...arr]``[?...obj]`

[**Explainer**](https://gist.github.com/askbeka/8bb17508ec250a789ea9bff683a50e38)

> <https://gist.github.com/askbeka/8bb17508ec250a789ea9bff683a50e38>

---

<div class="post-metadata">

**Author:** ![mikesamuel](https://yyz2.discourse-cdn.com/free1/user_avatar/es.discourse.group/mikesamuel/32/137_2.png) [@mikesamuel](https://es.discourse.group/u/mikesamuel)\
**Post date:** [November 15, 2019, 8:53pm UTC](https://es.discourse.group/t/optional-spreading/93/2 "2019-11-15T20:53:34Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![mikesamuel](https://yyz2.discourse-cdn.com/free1/user_avatar/es.discourse.group/mikesamuel/32/137_2.png) [@mikesamuel](https://es.discourse.group/u/mikesamuel)\
**Post date:** [November 15, 2019, 8:55pm UTC](https://es.discourse.group/t/optional-spreading/93/3 "2019-11-15T20:55:36Z")

</div>

> **TLDR** `[?...arr]``[?...obj]`

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

---

<div class="post-metadata">

**Author:** ![askbeka](https://yyz2.discourse-cdn.com/free1/user_avatar/es.discourse.group/askbeka/32/119_2.png) [@askbeka](https://es.discourse.group/u/askbeka)\
**Post date:** [December 19, 2019, 1:42pm UTC](https://es.discourse.group/t/optional-spreading/93/4 "2019-12-19T13:42:45Z")

</div>

Ooops. Thanks:) You are right

---

<div class="post-metadata">

**Author:** ![askbeka](https://yyz2.discourse-cdn.com/free1/user_avatar/es.discourse.group/askbeka/32/119_2.png) [@askbeka](https://es.discourse.group/u/askbeka)\
**Post date:** [December 19, 2019, 1:44pm UTC](https://es.discourse.group/t/optional-spreading/93/5 "2019-12-19T13:44:13Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![askbeka](https://yyz2.discourse-cdn.com/free1/user_avatar/es.discourse.group/askbeka/32/119_2.png) [@askbeka](https://es.discourse.group/u/askbeka)\
**Post date:** [February 15, 2020, 3:53pm UTC](https://es.discourse.group/t/optional-spreading/93/6 "2020-02-15T15:53:27Z")

</div>

Submitted [Optional spreading proposal](https://es.discourse.group/t/optional-spreading-proposal/224), since I cannot edit the topic in here
