Home  >  Article  >  Web Front-end  >  Performance issues of javascript string concatenation (multiple browsers)_javascript skills

Performance issues of javascript string concatenation (multiple browsers)_javascript skills

WBOY
WBOYOriginal
2016-05-16 18:58:35887browse

书中附带的测试代码如下 

复制代码 代码如下:



Example


Note: The latest versions of Firefox seem to have fixed the string concatenation problem. If you are using Firefox 1.0 or later, the string buffer may actually take longer than normal string concatenation.








在 Firefox/3.0.3中执行的结果如下:
Concatenation with plus: 5 milliseconds
Concatenation with StringBuffer: 10 milliseconds
在IE6中执行结果如下:
Concatenation with plus: 234 milliseconds
Concatenation with StringBuffer: 62 milliseconds
1.两种方式性能差别很大
2.看来IE6字符串连接处理能力比FF3很差呀
3.IE6和FF3两种方式结果相反,看来以后写连接优化还有注意浏览器呀
Statement:
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