I need to concat hundreds of Javascript strings like this:
var result = '';
for (var i = 0; i < 300; i ++ ) {
result += DATA[i] + 'Some Dynamic Text';
}
The DATA[i]
is pretty large (Like 300KB or more, it's image's base64 represents).
When I execute this code, the browser pops up an memory overflow error.(The break point is result += DATA[i]
)
How can I optimize this code to avoid this kind of memory issue ?
==== EDIT ====
I didn't make it clear before, so you can consider the DATA[i]
is pretty large and I can't change it. Every concat is also append some dynamic text.