Also, what's even more crazy is that destructuring {0: foo, 1: bar} can be faster in some javascript engines when destructuring an array with two or three element.
Yeah, absolutely. With the linked benchmark I just got the following results on desktop Linux:
- 17M ops/s ± 1.65% for array destructuring in Chrome
- 169M ops/s ± 0.78% for object destructuring in Chrome
- 545M ops/s ± 3.68% for array destructuring in Firefox
- 81M ops/s ± 0.8% for object destructuring in Firefox
So per the principle of "optimize for the bottleneck", one could choose to use object destructuring, because the slowest Firefox is still comparable to the fastest Chrome option. Or when, for example, you're running Node on a server and know which JS engine you're using.
Also, what's even more crazy is that destructuring {0: foo, 1: bar} can be faster in some javascript engines when destructuring an array with two or three element.