CodeX

Everything connected with Tech & Code. Follow to join our 1M+ monthly readers

Follow publication

Member-only story

How many times a string length can be greater than its size in memory?

Marian C.
CodeX
Published in
5 min readSep 11, 2021

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.

How concatenation results are stored

Create an account to read the full story.

The author made this story available to Medium members only.
If you’re new to Medium, create a new account to read this story on us.

Or, continue in mobile web

Already have an account? Sign in

CodeX
CodeX

Published in CodeX

Everything connected with Tech & Code. Follow to join our 1M+ monthly readers

Marian C.
Marian C.

Written by Marian C.

Java, JavaScript and SQL developer. Interested in data collection and visualization.

No responses yet

Write a response