Destructuring for Array-like objects

Frederick Stark coagmano at gmail.com
Wed Mar 20 02:22:12 UTC 2019


This already works with an iterator, because array destructuring uses the iterator protocol

const [a, b] = {
0: "ayy",
1: "bee",
length: 2,
*[Symbol.iterator]() {
let i = 0;
while (i < this.length) {
yield this[i]
i++
}
},
};

On Mar 20 2019, at 11:59 am, Sultan <thysultan at gmail.com> wrote:
> Afford array destructuring to Array-like objects.
>
> const [a, b] = {0: a, 1: b, length: 2}
>
> _______________________________________________
> es-discuss mailing list
> es-discuss at mozilla.org
> https://mail.mozilla.org/listinfo/es-discuss
>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20190320/10383521/attachment.html>


More information about the es-discuss mailing list