/
Javascript strings are immutable
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;
}
, multiple selections available,
Related content
Using an array to concatenate a long string
Using an array to concatenate a long string
More like this
How do I join strings together?
How do I join strings together?
More like this
Iterating through an array
Iterating through an array
More like this
Dealing with loops with create Closures
Dealing with loops with create Closures
More like this
How can do some funky thing with strings that I don't know?
How can do some funky thing with strings that I don't know?
More like this
How const can be helpful in modern Javascript
How const can be helpful in modern Javascript
More like this