Webcourse/04-JavaScript基础/14-字符串的深入学习.md
2020-05-15 10:12:45 +08:00

17 lines
400 B
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

## 字符串的不可变性
字符串里面的值不可被改变虽然看上去可以改变内容但其实是地址变了内存中新开辟了一个内存空间
代码举例
```js
var str = 'hello';
str = 'qianguyihao';
```
比如上面的代码当重新给变量 str 赋值时常量`hello`不会被修改依然保存在内存中str 会改为指向`qianguyihao`