# Optional keys in objects

**URL:** <https://es.discourse.group/t/optional-keys-in-objects/523>\
**Category:** 💡 Ideas\
**Tags:** proposal\
**Created:** [November 3, 2020, 8:10am UTC](https://es.discourse.group/t/optional-keys-in-objects/523 "2020-11-03T08:10:51Z")\
**Posts on this page:** 1\
**Showing post:** 7

<div class="post-metadata">

**Author:** ![theScottyJam](https://yyz2.discourse-cdn.com/free1/user_avatar/es.discourse.group/thescottyjam/32/616_2.png) [@theScottyJam](https://es.discourse.group/u/theScottyJam)\
**Post date:** [February 10, 2021, 5:45am UTC](https://es.discourse.group/t/optional-keys-in-objects/523/7 "2021-02-10T05:45:06Z")

</div>

Dart has a similar idea to @claudiameadows proposal, called "collection if" and "collection for", but it only works on array.

Example from Dart's website:

```javascript
var nav = [
  'Home',
  'Furniture',
  'Plants',
  if (promoActive) 'Outlet'
];

```

Such syntax would be nice in javascript too.

---

_[View the full topic](https://es.discourse.group/t/optional-keys-in-objects/523)._
