javascript JavaScript中的字符串

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了javascript JavaScript中的字符串相关的知识,希望对你有一定的参考价值。

/*In JavaScript, String values are immutable, which means that they cannot be altered once created.

For example, the following code:*/

var myStr = "Bob";
myStr[0] = "J";

// cannot change the value of myStr to "Job", because the contents of myStr cannot be altered.
// Note that this does not mean that myStr cannot be changed, just that the individual characters 
// of a string literal cannot be changed. The only way to change myStr would be to assign it with a 
// new string, like this:

var myStr = "Bob";
myStr = "Job";

以上是关于javascript JavaScript中的字符串的主要内容,如果未能解决你的问题,请参考以下文章

javascript JavaScript中的JSON字符串比较

JavaScript Javascript中的Sprintf(字符串格式)

javascript javascript.js中的随机字符串

转义 JavaScript 字符串中的单引号以进行 JavaScript 评估

JavaScript 字符串是不可变的吗?我需要 JavaScript 中的“字符串生成器”吗?

JavaScript 字符串是不可变的吗?我需要 JavaScript 中的“字符串生成器”吗?