When I want to loop through an array and add a string behind every element,
I can either
for(var x in array){
array[x] += "string";
}
or
for(var x, y = array.length; x<y; x++){
array[x] += "string";
}
But is there any difference in terms of performance between these 2 for loops?
It is recommended that you don’t use
for ... into iterate over arrays.i.e. Why is using "for…in" with array iteration a bad idea?
You should use
for ... into iterate over object properties only.