We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents 21a67ee + 4b10a73 commit 07bda80Copy full SHA for 07bda80
docs/2-browser-apps/02-reference/index.mdx
@@ -33,8 +33,16 @@ document.write(object1.age);
33
34
:::tip
35
上で説明したように、オブジェクトを変数に代入するとき、実際に代入されているのはオブジェクトの**参照**です。
36
-そのため、`const` による宣言で禁止されるのはその変数への代入だけであり、オブジェクトのプロパティへの代入はこれにあたりません。
37
-`const`で宣言しているにもかかわらず、そのプロパティが書き換わっていることがあるので注意しましょう。
+
+`const` による宣言で禁止されるのはその変数への再代入だけであり、オブジェクトのプロパティの変更は参照を変えないためこれにあたりません。
38
+そのため、`const`で宣言しても、そのプロパティを書き換えることができてしまうので注意しましょう。
39
40
+```js
41
+const tanaka = { name: "田中", age: 18 };
42
+tanaka.age = 19; // エラーにならず、代入できてしまう
43
+document.write(tanaka.age); // 19 と表示される
44
+```
45
46
:::
47
48
## ネストされたオブジェクト
0 commit comments