JavaScript for-loop alternative: repeat(n, function(i) { … });

前端 未结 5 888
臣服心动
臣服心动 2021-02-09 22:05

This is the regular for-loop:

for (var i = 0; i < n; i++) { ... }

It is used to iterate over arrays, but also to just repeat some process

5条回答
  •  孤城傲影
    2021-02-09 22:18

    Besides what you have already stated the main downside I see is that a "return" statement will work differently. (Which is often why I end up using "for" over "$.each" many times in my own ventures.)

提交回复
热议问题