I was doing a practice problem that involved concatenating strings in a for loop. I saw some info on older related questions on this site, but I wanted to know some other details. The book I got the practice problem from (Cracking the Coding Interview) did the solutions in Java. Here is a simplified version of the code just to get the point across:
for(int i = 0; i < str.length; i++){
string += str.charAt(i) + i;
}
The book pointed out how this is slow because string concatenation in Java operates in O(n^2). And the solution to this was to use the StringBuilder class in java.
However, how would this work in Javascript? Does string concatenation using "+=" also work in O(n^2) time?