JRS: In article <d5cd7hzi.fsf@hotpop.com>, dated Mon, 10 Jul 2006
14:38:09 remote, seen in news:comp.lang.javascript, Lasse Reichstein
Nielsen <lrn@hotpop.composted :
Quote:
>ipellew@pipemedia.co.uk writes:
>
Quote:
>Whats the maximum string length in Javascript.
Quote:
>If we insist that all lengths must be expressible exactly as a number,
>then the limit will be 2^53. At one byte per character (which is
ECMA requires 16-bit units, but not that they are characters.
Quote:
>probably too low), that requires ~8 petabyte of memory. So this
>theoretical limit is unlikely to be the limiting factor.
>
>A more likely limit is the range of an UInt32.
Some routines use -1 or lower, which could change that to SInt32.
Some implementations seem likely to use DWORD internally, imposing a
limit at 2^32-1 bytes.
Quote:
>A quick script to check the limit (although probably not in reasonable
>time):
>
>var N = 32; // vary this and see if it works.
>var x = "x";
>for(var i = 0; i < N; i++) { x= x+x; };
>alert(x.length)
>
>Try this in different browser, starting with a lower N and see when
>it breaks :)
Or put the alert inside the loop, changing it to a Confirm, and continue
the loop until the computer or the user gives out.
--
© John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v4.00 IE 4 ©
<URL:http://www.jibbering.com/faq/>? JL/RC: FAQ of news:comp.lang.javascript
<URL:http://www.merlyn.demon.co.uk/js-index.htmjscr maths, dates, sources.
<URL:http://www.merlyn.demon.co.uk/TP/BP/Delphi/jscr/&c, FAQ items, links.