Home > Web Front-end > JS Tutorial > body text

JS string accumulation Array is not necessarily faster than string accumulation (according to computer configuration)_javascript skills

WBOY
Release: 2016-05-16 17:53:36
Original
1137 people have browsed it

Post the complete code first.

Copy the code The code is as follows:


[code]

Let me talk about my machine configuration first, as shown in Figure 1:
JS string accumulation Array is not necessarily faster than string accumulation (according to computer configuration)_javascript skills.

The running time results are shown in Figure 2:
JS string accumulation Array is not necessarily faster than string accumulation (according to computer configuration)_javascript skills
The running results on an N old machine are shown in Figure 3:
JS string accumulation Array is not necessarily faster than string accumulation (according to computer configuration)_javascript skills
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.

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template