linkbait. the only optimization technique they give is
// Slow cycle
for(var i=0; i<items.length; i++) {
// code is here...
}
// this one is faster
var size = items.length;
for(var i=0;i<size; i++){
// code is here...
}
and that optimization isn't even a factor in v8 anymore because it caches `items.length`. Not sure about other engines.
The latter example could still be rewritten as:
for (var i=0,len=items.length; i<len; i++){
// code is here...
}
linkbait. the only optimization technique they give is // Slow cycle for(var i=0; i<items.length; i++) { // code is here... } // this one is faster var size = items.length; for(var i=0;i<size; i++){ // code is here... }and that optimization isn't even a factor in v8 anymore because it caches `items.length`. Not sure about other engines. The latter example could still be rewritten as: for (var i=0,len=items.length; i<len; i++){ // code is here... }