Do loops check the array.length every time when comparing i against array.length?

前端 未结 5 1446
一向
一向 2020-11-30 07:44

I was browsing around and I found this:

var i, len;
for(i = 0, len = array.length; i < len; i++) {  
   //...
}

My first thoughts are:

5条回答
  •  有刺的猬
    2020-11-30 08:16

    Here are a number of performance tests for different approaches

    http://www.websiteoptimization.com/speed/10/

提交回复
热议问题