Is String.concat slower than Array approach to join strings
- by Rajat
Strings in JavaScript are immutable. Across the web and here on Stack Overflow as well, I came across the Array approach to concatenate strings:
var a = [];
a.push(arg1,arg,2....);
console.log(a.join(''));
I know that this approach is better than the simple
console.log(arg1 + arg2 +.....);
for reasons of skipping creating intermediate objects but how does it fair better against :
arg1.concat(arg2,arg3.....);