7 ms·
Because things like proxies exist, I guess. Also, what's even more crazy is that destructuring {0: foo, 1: bar} can be faster in some javascript engines when d
by vanderZwan 2y ago
Because things like proxies exist, I guess.
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.
- bryancoxwell 2y agoQuite a bit faster it looks like: https://jsbench.me/6zlvrupqmj/1 https://jsbench.me/6zlvrupqmj/1
- debugnik 2y ago91.86% slower on my Android phone with Firefox, so it definitely depends on which JS engine.
- vanderZwan 2y agoYeah, 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.
- vbezhenar 2y ago77M ops/s ± 0.31%; 1.3B ops/s ± 0.17% for Safari. Difference is huge 800M ops/s ± 0.5%; 837M ops/s ± 0.32% for Chrome on the same computer.
- Alifatisk 2y agoWhat a cool website!