Member-only story
How many times a string length can be greater than its size in memory?
512,000,000 characters long string needs ~1 MB of memory

Max length of a JavaScript string
According to ECMAScript specification a string cannot contain more than 9,007,199,254,740,991 (2⁵³-1) characters. Evidently, the achievable max length also depends on the computer capacity. Also browsers can set their limits. The max string length set in the Chrome source code is 536.8 millions characters. To simplify the sample code, in this post I experiment with a slightly shorter 512 million characters long string.
Similarity between strings and objects
In JavaScript, strings and other primitive types differ from objects in that they cannot have properties. But there is a similarity between string and objects that might be important for optimization of a web application performance. Like objects, string values are accessed through references held by variables. When a string variable is assigned to another variable, not the string value, but the reference to the string location in memory is copied to the target variable.