Monday, June 3, 2024
 Popular · Latest · Hot · Upcoming
180
rated 0 times [  187] [ 7]  / answers: 1 / hits: 36318  / 11 Years ago, sun, june 2, 2013, 12:00:00

I'm writing JavaScript unit tests and I need to create a string of length 65536.
What's the best way to do this in JavaScript?



Currently I'm using:



var myString = '';
for (var i = 0; i <= 65535; ++i) {
myString += 'x';
}

More From » string

 Answers
37

How about



Array(65537).join('x')


Note, that it's 65537, not 65536, because you put characters inbetween.


[#77864] Friday, May 31, 2013, 11 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
adrienb

Total Points: 500
Total Questions: 104
Total Answers: 104

Location: Australia
Member since Sat, May 27, 2023
1 Year ago
;