gpt4 book ai didi

javascript - 术语 'binding' 在 JS 中是什么意思?

转载 作者:行者123 更新时间:2023-12-01 16:25:42 24 4
gpt4 key购买 nike

请为我说明 绑定(bind) 在 JavaScript 中的含义。我开始阅读“Eloquent JS”这本书,这个词出现了很多次。只是变量的意思吗?以下是书中的几个例子:

  1. 因此,如果您知道您感兴趣的属性称为颜色,您会说 value.color。如果你想提取由 binding i 中保存的值命名的属性,你说 value[i]。属性名称是字符串。它们可以是任何字符串,但点符号仅适用于看起来像有效 binding 名称的名称。
  2. 绑定(bind) 也可以是可变的或不变的,但这与其值的行为方式是分开的。即使数字值不变,您也可以使用 let 绑定(bind)通过更改 binding 指向的值来跟踪不断变化的数字。类似地,虽然 const 绑定(bind) 到一个对象本身不能更改并且将继续指向同一个对象,但该对象的内容可能会更改。

最佳答案

我已经知道它是什么了(在这本书的前一章)。这是片段:

How does a program keep an internal state? How does it remember things? We have seen how to produce new values from old values, but this does not change the old values, and the new value has to be immediately used or it will dissipate again. To catch and hold values, JavaScript provides a thing called a binding, or variable:

let caught = 5 * 5;

That’s a second kind of statement. The special word (keyword) let indicates that this sentence is going to define a binding. It is followed by the name of the binding and, if we want to immediately give it a value, by an = operator and an expression.

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.

关于javascript - 术语 'binding' 在 JS 中是什么意思?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62093518/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com