4 ms·
As usual, it's best not to sacrifice readability for performance until you have proof of a bottleneck. Most of the code you write isn't performance-critical. An
by jdlshore 13y ago
As usual, it's best not to sacrifice readability for performance until you have proof of a bottleneck. Most of the code you write isn't performance-critical. And (thanks to existing performance optimizations in everything ranging from the JS VM, to the OS, to the CPU itself) it's very, very easy to be wrong about where your performance problems are. Note the comments under the SO article; most of the micro-"optimizations" are actually slower than normal code.
Also, it answers the question wrong. :-b (Arrays are objects in JS, with a bit of extra magic.)