# Object Array Pick

**URL:** <https://es.discourse.group/t/object-array-pick/992>\
**Category:** 💡 Ideas\
**Created:** [September 23, 2021, 12:42pm UTC](https://es.discourse.group/t/object-array-pick/992 "2021-09-23T12:42:32Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![ethanlal04](https://yyz2.discourse-cdn.com/free1/user_avatar/es.discourse.group/ethanlal04/32/918_2.png) [@ethanlal04](https://es.discourse.group/u/ethanlal04)\
**Post date:** [September 23, 2021, 12:42pm UTC](https://es.discourse.group/t/object-array-pick/992/1 "2021-09-23T12:42:32Z")

</div>

I couldn't find a better name.

Just a small idea of picking props off an object and smashing them into an array.

```javascript
const person = {
  age: 12,
  name: "Ethan",
};

person.["age", "name"]; // [12, "Ethan"]

```

I've seen [this](https://es.discourse.group/t/const-b-a-id-name-age-object-cherry-pick/905) idea that shows a similar way to get a subset of an object. If it will exist, why shouldn't this? I find it like having object destructuring but not array destructuring.

Any thoughts?

PS: I happen to have given the 400th post!

PS: I didn't use `person["age", "name"]` because for some reason it happens to be valid JS.

---

<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:** [September 23, 2021, 1:40pm UTC](https://es.discourse.group/t/object-array-pick/992/2 "2021-09-23T13:40:23Z")

</div>

Perhaps there's use cases for a syntax like this, but I can't think of any time when I've had an object, and I wanted to put specific property values into a specific order in an array like this.

Can you think of any use cases for such a syntax?

---

<div class="post-metadata">

**Author:** ![ljharb](https://yyz2.discourse-cdn.com/free1/user_avatar/es.discourse.group/ljharb/32/8_2.png) [@ljharb](https://es.discourse.group/u/ljharb)\
**Post date:** [September 23, 2021, 4:39pm UTC](https://es.discourse.group/t/object-array-pick/992/3 "2021-09-23T16:39:18Z")

</div>

`['age', 'name'.map(x => person[x])` is not much longer than your suggested example and follows existing JS idioms.

I also have never seen a use case for this, though, and would love to hear more.
