Conversation
bf5fed0 to
1153079
Compare
Deploying utcode-learn with
|
| Latest commit: |
a5ef48a
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://e1538c45.utcode-learn.pages.dev |
| Branch Preview URL: | https://rewrite-variable-scope.utcode-learn.pages.dev |
1153079 to
1c4b02e
Compare
|
|
||
| function greet() { | ||
| guestCount += 1; | ||
| guestCount = guestCount + 1; |
There was a problem hiding this comment.
ここで初出の += が出てくるとノイズなので、ここでは普通に今まで扱った方法で書き、下のコラム内で「これを += に書き換えられる」という説明をするようにしています
|
|
||
| greet(); | ||
|
|
||
| // document.write(message); これはエラーになる |
There was a problem hiding this comment.
エラーになるサンプルコードを提供しない、という方針に従いコメントアウトしている
There was a problem hiding this comment.
Pull request overview
「変数のスコープ」セクションを、具体例(関数内のローカル変数/外側で宣言した変数の参照)を用いて説明し直し、合わせて複合代入演算子の説明導線を整理するPRです。
Changes:
- スコープの説明を、
messageのローカルスコープ例(関数内のみ参照可)で具体化 - 外側(関数外)で宣言した変数を関数内から参照・更新できる例を維持しつつ、説明文をリライト
- 複合代入演算子の説明を「
guestCount = guestCount + 1→guestCount += 1」の流れに整理
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
3ee392d to
a5ef48a
Compare
|
|
||
| ```javascript | ||
| function greet() { | ||
| let message = "Hello!"; |
There was a problem hiding this comment.
ここでconstではなく、letを使った理由が分からなかったのですが、何かあったりしますか?
|
|
||
| ```javascript | ||
| function greet() { | ||
| let message = "Hello!"; |
There was a problem hiding this comment.
(optional)
上の説明では、メッセージが"Hello!"ではなく、"Hello World!"になっているため、そちらに統一すると認知負荷が少し小さくなるかもしれません。
utcode-learn/docs/1-trial-session/09-functions/index.mdx
Lines 11 to 20 in 27d5138
|
|
||
| ```javascript | ||
| function greet() { | ||
| let message = "Hello!"; |
|
|
||
| greet(); | ||
|
|
||
| // document.write(message); これはエラーになる |
There was a problem hiding this comment.
(optional)
これを単にコメントアウトすると、document.write(message); これはエラーになるとなってしまい、これも構文エラーになってしまうため、単にコメントアウトしても構文エラーにならないようになっていると少し親切かもしれません。
resolves #815