I thought this would be an easy google search but nothing came up.
Say I create a loop that continually appends one character at a time to a variable.
At what point will the program crash?
I expect it will take <6 seconds for someone to comment "Why don't you try it and find out?", but trying it wouldn't tell me the answer to the question. Is it implementation-specific? Is it defined anywhere? It doesn't seem to be in the ECMAScript spec.
Are there any known limitations beyond available memory? Does performance degrade with strings holding Mbs or Gbs of text?
For the record, I did try running that loop....and it just crashed my browser :( Maybe if I make some adjustments and try again.
ECMAScript 2016 (ed. 7) established a maximum length of
2^53 - 1
elements. Previously, no maximum length was specified. In Firefox, strings have a maximum length of2**30 - 2
(~1GB). In versions prior to Firefox 65, the maximum length was2**28- 1
(~256MB).
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/length
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With