Home >Web Front-end >JS Tutorial >JS string accumulation Array is not necessarily faster than string accumulation (according to computer configuration)_javascript skills
Post the complete code first.
Let me talk about my machine configuration first, as shown in Figure 1:
.
The running time results are shown in Figure 2:
The running results on an N old machine are shown in Figure 3:
The above bunch of codes and pictures may be messed up. The summary is as follows:
When the machine configuration is low: "" The time consumed by the string splicing method is significantly higher than that of the Array method.
When the machine configuration is high: "" The time consumed by the string splicing method may be different from that of the Array method. flat. Or even shorter.
Summary: Just to be on the safe side. It is still recommended to use Array for string splicing operations.