Why is String immutable in JavaScript?

JavaScript strings are immutable. This means that once a row is created, it cannot be changed. However, it is still possible to create another row based on the operation on the original row

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures

I understand what immutable value means , but I need to know why they built it like this and what is the value of this immutable approach?

Note. I have looked at the Java link , but I am not a Java developer and I cannot understand the terms there (StringPool, hashcode ...)

+3
javascript


source to share


No one has answered this question yet

See similar questions:

202
Are JavaScript strings immutable? Do I need a "string builder" in JavaScript?
117
Why is the String class declared final in Java?
78
What's the difference between JavaScript and Java?
56
Why are strings immutable in many programming languages?
7
Why String is immutable or final in Java

or similar:

7649
How does JavaScript blocking work?
7494
How can I remove a specific element from an array in JavaScript?
7432
How to check if a string contains a substring in JavaScript?
7287
What does "use strict" do in JavaScript, and what are the reasons for it?
5722
How can I remove a property from a JavaScript object?
5670
Which operator is equal (== vs ===) should be used in JavaScript comparisons?
5101
What's the most efficient way to deeply clone an object in JavaScript?
4829
How do I include a JavaScript file in another JavaScript file?
4380
For each by an array in JavaScript?
3999
How do I replace all occurrences of a string?



All Articles
Loading...
X
Show
Funny
Dev
Pics