变量、绑定与手柄

对象常量的属性能够改变的?

`值常量看似是“值不能变”意思,事实符号绑定不变,由于变量只是个手柄(地址引用),非容器
编程

`对象常量,不是对象内容不变,是对象引用(手柄)不能变
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"
};
复制代码

变量与符号绑定技术

1 符号绑定一个计算结果

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

2 符号能够解绑定

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复制代码

3 可见符号变量只是一个引用/手柄,而非容器

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

为何须要符号绑定

  • 中间计算
  • 复杂的计算(计算集中,数据集中)都是多步的
  • 符号能够抽象,表达复杂多步计算,符号种类有变量,表达,函数和类对象等多种粒度
相关文章
相关标签/搜索