`值常量看似是「值不能變」意思,事實符號綁定不變,由於變量只是個手柄(地址引用),非容器
編程
`對象常量,不是對象內容不變,是對象引用(手柄)不能變
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