3 ms·
That reduces the number of string appends, sure. But it is well known (see either "The Good Parts" or "High Performance Javascript" that appending strings is q
by nod 15y ago
That reduces the number of string appends, sure. But it is well known (see either "The Good Parts" or "High Performance Javascript" that appending strings is quadratic in JavaScript, and that the best way to assemble a large, multipart string is arrayOfStrings.join('');
* And by quadratic I mean "copies the whole string every time" such that an append loop is N^2 while a push+join is linear.
- rimantas 15y agoBut it is well known (see either "The Good Parts" or "High Performance Javascript" that appending strings is quadratic in JavaScript, and that the best way to assemble a large, multipart string is arrayOfStrings.join(''); It's a bit fuzzy now, modern browser optimized that quite a bit, so this mainly applies to older versions of IE.