What’s the Fastest Way to Code a Loop in JavaScript

development, javascript Add comments

Link: What’s the Fastest Way to Code a Loop in JavaScript

作者对JS的几种循环方式作了详细的测试,测试页面在这里,具体测试结果可以进入网站查看。

通过测试结果可以看出

var i = arr.length; while (i--) {}

这种方式速度是最快的。

在测试过程中,作者有个有趣的发现,对于HTML的集合,使用hColl.item(i)hColl[i] 慢2-6倍(在Safari中除外)

  • Share/Bookmark

No related posts.

Related posts brought to you by Yet Another Related Posts Plugin.

Leave a Reply


WP Theme & Icons by N.Design Studio
Entries RSS Comments RSS Log in