1 var str = "I'm a thirty-five character string.",
 2     strs = [],
 3     newStr,
 4     appends = 5000;
 5 
 6 while (appends--) {
 7     strs[strs.length] = str;
 8 }
 9 
10 newStr = strs.join("");

以上代码为了让IE7或者更低版本的浏览器性能更优。其他浏览器使用以下代码:

1 var str = "I'm a thirty-five character string.",
2     newStr = "",
3     appends = 5000;
4 
5 while (appends--) {
6     newStr += str;
7 }

相关文章:

  • 2022-12-23
  • 2021-05-11
  • 2021-11-19
  • 2022-12-23
  • 2021-06-29
  • 2021-12-31
猜你喜欢
  • 2021-11-07
  • 2022-12-23
  • 2022-12-23
  • 2021-07-31
  • 2021-05-23
  • 2021-12-31
  • 2022-02-07
相关资源
相似解决方案