Let on an array,
Method 1:
var array = ["a","a","a","a","a"];
for(var i=1; i<=array.length; i++)
array[i-1] += i;
console.log(array);
Method 2:
var array = ["a","a","a","a","a"];
var i = 1;
array.forEach(function(){
array[i-1] += i;
i++;
});
console.log(array);
Both methods on array yields same result, that is:
["a1","a2","a3","a4","a5"]
But
1) which is the fastest method?
2) Is there any other faster way to do the same thing that is convert ["a","a","a","a","a"] to ["a1","a2","a3","a4","a5"]?
3) Is there a way to know time taken by both code snippet? Please don't be too technical...