`值常量看似是“值不能变”意思,事实符号绑定不变,由于变量只是个手柄(地址引用),非容器
编程
`对象常量,不是对象内容不变,是对象引用(手柄)不能变
bash
Object Declarations with const A const declaration prevents modification of the binding, not of the value.
ide
const声明防止绑定的修改,而不是值的修改
函数
That means const declarations for objects don’t prevent modification of those objects. For example:
ui
const person = {
name: "Nicholas"
};
// works 改内容不出错
person.name = "Greg";
// throws an error 改绑定出错
person = {
name: "Greg"
};
复制代码
To catch and hold values, JavaScript provides a thing called a binding, or variable:
spa
let caught = 5 * 5;复制代码
The previous statement creates a binding called caught and uses it to grab hold of the number that is produced by multiplying 5 by 5.
code
When a binding points at a value, that does not mean it is tied to that value forever. The = operator can be used at any time on existing bindings to disconnect them from their current value and have them point to a new one.
对象
let mood = "light";
console.log(mood);
// → light
mood = "dark";
console.log(mood);
// → dark复制代码
You should imagine bindings as tentacles, rather than boxes. They do not contain values; they grasp them—two bindings can refer to the same value. A program can access only the values that it still has a reference to. When you need to remember something, you grow a tentacle to hold on to it or you reattach one of your existing tentacles to it.
ip
一个技术实现的概念,例如编译器,一个是编程的概念,是高级语言的应用概念
rem