slow_loop.md

August 5, 2016 · View on GitHub

Slow Loop Back

###Problem

/* from Google Closure 
 * from array.js, Line 63
 * 每次循環都要查找屬性值而增加開銷
*/
for (var i = fromIndex; i < arr.length; i++) {

###Solution

/*
 * Use a variable to store the value of attributes
*/
for (var i = fromIndex, len = arr.length; i < len; i++) {