TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

What's the Fastest Way to Code a Loop in Javascript?

22 点作者 rbxbx将近 15 年前

6 条评论

Sharlin将近 15 年前
Given the amount of work that has gone into optimizing Javascript speed in browsers during the past two years, I'd say these results are completely obsolete.
评论 #1504404 未加载
code_duck将近 15 年前
So, anyone have results for browsers that were released within the past 2 years?
评论 #1504592 未加载
donohoe将近 15 年前
What surprises me is are some of the results like this:<p><pre><code> IE 7.0.5730.11 / WinXP SP2 Native Array (length=1000, looped 100 times) </code></pre> While loop in reverse, simplifying the test condition.<p><pre><code> var i = arr.length; while (i--) {} </code></pre> Took <i>0ms</i> to execute... very unexpected
评论 #1504446 未加载
jallmann将近 15 年前
Some very interesting results -- I didn't expect the while loop in reverse to be so fast, and this is consistent across browsers.<p>The presentation needs work, though. Would some charts be so difficult to make? Much easier to compare results that way.<p>edit: note this post is from 2008.
评论 #1504345 未加载
hackermom将近 15 年前
I personally always (when applicable, of course) go with a reversed while-loop, because of its neat and tidy nature, and being "easy on the eye".
elimisteve将近 15 年前
Using emacs :-)