# Allow "awaiting" on arrays

**URL:** <https://es.discourse.group/t/allow-awaiting-on-arrays/178>\
**Category:** 💡 Ideas\
**Tags:** proposal\
**Created:** [December 31, 2019, 2:06am UTC](https://es.discourse.group/t/allow-awaiting-on-arrays/178 "2019-12-31T02:06:53Z")\
**Posts on this page:** 1\
**Showing post:** 16

<div class="post-metadata">

**Author:** ![JackWorks](https://yyz2.discourse-cdn.com/free1/user_avatar/es.discourse.group/jackworks/32/260_2.png) [@JackWorks](https://es.discourse.group/u/JackWorks)\
**Post date:** [May 27, 2020, 3:38am UTC](https://es.discourse.group/t/allow-awaiting-on-arrays/178/16 "2020-05-27T03:38:11Z")

</div>

I have a better polyfill now, it won't delete & restore the prototype @ljharb

Still, DONT USE IT IN YOUR PRODUCT

```javascript
Array.prototype.then = async function (resolve, reject) {
    class NonThenableArray extends Array {}
    NonThenableArray.prototype.then = 0
    NonThenableArray.prototype[Symbol.species] = NonThenableArray
    const result = new NonThenableArray()
    // This won't make promises parallel
    for (const p of this) {
        try { result.push(await p) }
        catch (e) { return reject(e) }
    }
    resolve(result)
}

```

---

_[View the full topic](https://es.discourse.group/t/allow-awaiting-on-arrays/178)._
