M
M
mester2012-08-26 03:23:01
JavaScript
mester, 2012-08-26 03:23:01

Optimizing the concatenation of a large number of strings - does it work?

I came across in search of methods for optimizing the speed of the JS site on this method:

// Пример 1 - использование конкатенации
var str = "Вычисленная площадь равна " + sq + "м2, а объем соответственно " + v + "м3";

// Пример 2 - использование функции join().
var str2 = ["Вычисленная площадь равна " , sq , "м2, а объем соответственно " , v , "м3"].join("");


Does it really give a significant performance boost when using join? Or is it match optimization?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
avalak, 2012-08-26
@mester

Is it really that hard to test ? (console output).
// Конкатенация 100000 случайных строк test1: 36ms // + test2: 119ms // join

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question