3 ms·
What's the Fastest Way to Code a Loop in JavaScript?
- d0mine 18y agoThe benchmark is faulty but nonetheless informative.
- ajross 18y agoBeware: this is a microbenchmark. It tells you a little about the interpreter innards that get used for different kinds of syntax, but that's about it. Unless you're writing tight loops over small data, though (e.g. doing cryptography in Javascript or whatnot) this is not where you will be seeing slowdowns. In the real world, performance analysis always needs to start with the data. Are the questions you are asking your data algorithmically fast? Are you failing to cache things that are expensive to compute and hurting performance? Are you incorrectly caching things that are easy to compute and hurting performance? Those are the real problems. And they have nothing to do with for() vs. Array.forEach().
- notauser 18y ago(Almost on topic) There is a JavaScript meetup in London on the 13th of August. http://javascript.meetup.com/3/ http://javascript.meetup.com/3/
- geuis 18y agothis is potentially very useful info. In what ways is the benchmark wrong?