ip*****@pipemedia.co.uk wrote:
Whats the maximum string length in Javascript.
Are you asking about the value of a string primitive or the maximum
length of a string literal in source code? I have never seen stated
values for any maximum length of a string primitive's value (so
probably limited by available memory), and have seen practical tests
going into the hundreds of millions of characters (so probably
exceeding all practical needs). Microsoft used to claim a size limit
for a string literal token, but previous discussions on the subject
proved that the stated figure no longer applied and that the current
real figure is so large that nobody wanted to waste the time necessary
to find out what the limit was.
Is it the same across all the browsers?
There is no reason to expect any limit to be the same across browsers
except by coincidence (such as would result from using a 32bit integer
value to hold the length in different implementations). If in practice
the limiting factor tends to be available memory then all browsers on
the same machine will have the same available memory.
max_s_len = str.length // what the max number of chars we can
have is str?
If you really must know you can carry out your own tests. You will find
that as the strings get bigger the code slows down so much that you
will get fed up with waiting before you find a definitive answer.
Richard.