JSFiddle - React, Tailwind, and code Playground

by shapeshifta

JavaScript

//Arrays erzeugen
var test = [],
    final = [];

//Test mit Zahlen befĂĽllen
for(var i = 0; i < 100000; i++){
    test.push(i);  
}

//Start des Profilings
console.profile('ohne caching von length');
var test1 = function(){
    for(var i = 0; i < test.length; i++){
        final.push( test[i] );   
    }
    return final;
};
test1();
console.profileEnd();

//final resetten
final = [];

//Profiling Runde 2
console.profile('mit caching von length');
var test2 = function(){
    for(var i = 0, max = test.length; i < max; i++){
        final.push( test[i] );  
    }
    return final;
};
test2();
console.profileEnd();