Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

17
  • 8
    It would be better to back up these claims with benchmarks. Try jsperf.com. Commented Aug 21, 2013 at 13:58
  • 3
    lol jsperf... pls Matt just beacuse you don't like my answer stop downvoting my others ... stackoverflow.com/a/18344296/2450730 ... use console.time() or how it's called ... NOT jsperf. Commented Aug 21, 2013 at 14:00
  • 4
    FYI: As John Reisig first published a few years ago - on some platforms (meaning windows:P) time is being fed to the browser once every 16ms. Also there are other problems with measuring time of execution in multitasking environments. jsperf.com has implemented running the tests so that they are statistically correct. It's ok to run console.time() to get an intuition, but for a proof, you need jsperf.com AND it shows you cross-browser results from other people (different hardware etc) Commented Sep 14, 2013 at 8:58
  • 3
    @cocco this is incorrect: var a=[],b=N;while(b--){a[b]=a+1}; Commented May 15, 2015 at 23:28
  • 6
    @cocco— while isn't always faster than other loops. In some browsers, a decrementing while loop is much slower than a for loop, you can't make general statements about javascript performance like that because there are so many implementations with so many different optimisations. However, in general I like your approach. ;-) Commented Aug 9, 2015 at 23:57