Javascript strings are immutable
This means they never change. Most of the time it doesn’t matter.
function CONCATappendSlow(N){
console.time();
var H ='';
for (var i=0; i < N; i++){
H+='The quick' + " ";
}
console.timeEnd();
return H;
}
And this is a faster way of doing it.
function CONCATappendFast(N){
console.time();
var H = new Array(N);
for (var i=0; i < N; i++){
H[i] ='The quick';
}
console.timeEnd();
console.time();
var Result = H.join(' ');
console.timeEnd();
return Result;
}