for vs for in performance with strings (v2)

Revision 2 of this benchmark created on


Test runner

Ready to run.

Testing in
TestOps/sec
for normal
// Testing 'for' performance
var myArr = [ 'En', 'un', 'lugar', 'de', 'la', 'Mancha', 'de', 'cuyo', 'nombre', 'no', 'quiero', 'acordarme' ],
    myArrClone = [];

var l = myArr.length;
// Preparo un array de pruebas
for( var x = 0, i = l; x < i; x++ ){
    myArrClone.push( myArr[x] );
}
ready
for in variant
var myArr = [ 'En', 'un', 'lugar', 'de', 'la', 'Mancha', 'de', 'cuyo', 'nombre', 'no', 'quiero', 'acordarme' ],
    myArrClone = [];

for( var element in myArr ){
  myArrClone.push( myArr[element] );
}
ready

Revisions

You can edit these tests or add more tests to this page by appending /edit to the URL.