I have seen commas to concatenate primitive data types in Javascript and was wondering whether there was any difference in using a comma over say the + operator as well as the .concat() function?
So an example the following statement gives me abc
var value1 = a, value2 = b, value3 = c;
document.write(value1,value2,value3);
Since string concatenation is one of the haviest operations on computing, using
document.writewith various parameters would perform better.See this test (it sometimes hangs in IE, so use other browser please) http://jsperf.com/document-write-vs-concatenation
Explaination:
is equivalent to
Thus, being much faster, since it doesn’t concatenates the strings.