4 ms·
The rare case for me is when you really care about size. The destructured variables can be renamed by the minifier while an object will keep the property names.
by postalrat 4y ago
The rare case for me is when you really care about size. The destructured variables can be renamed by the minifier while an object will keep the property names.
- bastawhiz 4y agoThat's where gzip or brotli come in. In a lot of cases the number of bytes over the wire hardly changes.
- tonto 4y agomaybe interesting: the obj destructuring may be a bit faster than array destructuing (and not destructuring at all is sometimes a bit faster too). setup a small benchmark here https://jsbench.me/eolakmvsor/1 https://jsbench.me/eolakmvsor/1 just storing the data and accessing it as a tuple seems to not be the significantly slow part, but instead its destructuring the array that can be a bit slow. i remember seeing some threads with e.g. useState hooks in react needing array destructuring optimizations, but appears to still be a bit slower https://docs.google.com/document/d/1hWb-lQW4NSG9yRpyyiAA_9Ktytd5lypLnVLhPX9vamE/edit https://docs.google.com/document/d/1hWb-lQW4NSG9yRpyyiAA_9Kt... caveat: depends on browser (chrome vs firefox behavior is different for example) and may vary over time