Javascript for loop efficiency

后端 未结 5 589
我寻月下人不归
我寻月下人不归 2021-01-04 10:01

Is

for (var i=0, cols=columns.length; i

more efficient than

for (var i=0; i

        
5条回答
  •  走了就别回头了
    2021-01-04 10:33

    The cached version is faster but, the 2nd version safer.

    If you're just curious about which loop types are fastest you may want to check this out: http://blogs.oracle.com/greimer/resource/loop-test.html

提交回复
热议问题