It is Bip Bip Bipool

May 23, 2008

String Concate In JavaScript

Filed under: javascript — bipool @ 18:30

In JavaScript , String concatenation is too much slow. If you have some long string and need to concate in a loop.  It will take long  time to execute the process. If your loop iteration is like 2000 times and your string like 100 characters long, then it might take 7-8 seconds to execute. Thats a real fact for optimization. JavaScript actually store data in many places when concate  the string.

If you do following way then process time will reduce significantly. If you store every string in an array and then join the string using array.join(“”) function , it will reduce time. I got it reduces 70-75% time of previous one .

Theme: Banana Smoothie. Blog at WordPress.com.

Follow

Get every new post delivered to your Inbox.