3 ms·
Yes, this will be so much, much faster when your app calls this functions 1 million times!!! Awesome!!! You can probably save a whole millisecond or two!!! A p
by bisho 12y ago
Yes, this will be so much, much faster when your app calls this functions 1 million times!!! Awesome!!! You can probably save a whole millisecond or two!!!
A pity that for the average call count for this functions, the browser will expend much, much more loading and evaluating this code, rather than executing the function.
- mattwad 12y agoIt's a good point. When I started doing JS full-time, I wanted to squeeze out ever ms, writing for loops over using $.each or _.each, for example. But in the end, it just adds more lines of code and makes code harder to read. Also, the fact that each browser has significantly different results means you may need to implement different methods for each. There are times to maximize performance, but 95% of the time, you don't need the small boost. You're better off writing legible/maintainable code and using more high-level optimizations, like deferring heavy processes in a timeout.