In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly explains "is the string of javascript variable?" the content of the explanation in the article is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn "is the string of javascript variable?"
In javascript, the value of a string is immutable, which means that once a string is created, it cannot be changed; the reason: the string itself is a basic type encapsulated by the language, and the underlying layer is still an object, whose content cannot be changed since it is created, so the string remains unchanged.
The operating environment of this tutorial: windows7 system, javascript1.8.5 version, Dell G3 computer.
In JavaScript, the value of a string is immutable, which means that once a string is created, it cannot be changed.
For example, the following code:
Var myStr = "Bob"; myStr [0] = "J"
Will not change the value of the variable myStr to "Job", because the variable myStr is immutable.
Note that this does not mean that myStr can never be changed, but that individual characters of the literal string string literal cannot be changed.
The only way to change the myStr is to re-assign it a value, like this:
Var myStr = "Bob"; myStr = "Job"
Why are strings immutable in js?
In fact, the string itself is a basic type encapsulated by the language (new through the String constructor that comes with the system), and the underlying layer is still an object, not a simple data type. The content of this object cannot be changed since it was created, so the string remains unchanged.
Operations such as + will only generate a new string object, and the original string object will not change. If a string object is no longer referenced, it will be reclaimed by GC.
Thank you for reading, the above is the content of "variable string of javascript", after the study of this article, I believe you have a deeper understanding of the problem of variable string of javascript, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.