Skip to content

Commit 1c40aff

Browse files
committed
Clarify role of bindings in mutability/immutability
1 parent 9dc8f41 commit 1c40aff

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

04_data.md

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -407,9 +407,6 @@ same. The text inside it cannot be changed. If you have a string that
407407
contains `"cat"`, it is not possible for other code to change a
408408
character in your string to make it spell `"rat"`.
409409

410-
_Bindings_ to such values can be changed, of course, as long as they
411-
are not `const`. But that is different from changing the value itself.
412-
413410
The content of an object value _can_ be modified, by changing its
414411
properties.
415412

@@ -445,6 +442,15 @@ is why changing `object1` also changes the value of `object2`. The
445442
binding `object3` points to a different object, which initially
446443
contains the same properties as `object1` but lives a separate life.
447444

445+
{{index "const keyword", "let keyword"}}
446+
447+
Bindings can also be changeable or constant, but this is separate from
448+
the way their values behave. Even though number values don't change,
449+
you can use a `let` ((binding)) to keep track of a changing number by
450+
changing the value it points at. Similarly, though a `const` binding
451+
to an object can itself not be changed and will continue to point at
452+
the same object, the _contents_ of that object might change.
453+
448454
{{index "== operator", [comparison, "of objects"], "deep comparison"}}
449455

450456
When you compare objects with JavaScript's `==` operator it will

0 commit comments

Comments
 (0)