Skip to content

fix: 「関数とスコープ」における誤字脱字の訂正など #1594

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Feb 20, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions source/basic/function-scope/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,7 @@ measureTask(doHeavyTask);

コードの量が増えていくにつれ、人が一度に把握できる量にも限界がやってきます。
そのため、人が一度に把握できる範囲のサイズに処理をまとめていくことが必要です。
この問題を解決するアプローチとして、変数の参照できる範囲を小さくすることや処理を関数にまとめるという手法がよく利用されます
この問題を解決するアプローチとして、変数を参照できる範囲を小さくするために、処理を関数にまとめるという手法がよく利用されます

## 関数スコープとvarの巻き上げ {#hoisting-var}

Expand Down Expand Up @@ -411,7 +411,7 @@ var_x = "varのx";
次に、`let`と`var`で異なる動作を見ていきます。

`let`では、変数を**宣言する前**にその変数を参照すると`ReferenceError`の例外が発生して参照できません。
次のコードでは、変数を宣言する前に、変数`x`を参照したため`ReferenceError`となっています。
次のコードでは、変数を宣言する前に変数`x`を参照したため`ReferenceError`となっています。
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ここは明確な誤りではないですが、読点が不要であると感じられたため削除しました。

エラーメッセージから、変数`x`が存在しないからエラーになっているのではなく、実際に宣言した行より前に参照したためエラーとなっているのがわかります。[^1]

{{book.console}}
Expand Down Expand Up @@ -857,7 +857,7 @@ const createCounter = () => {
// countUpとnewCountUpはそれぞれ別のincrement関数(内側にあるのも別のcount変数)
const countUp = createCounter();
const newCountUp = createCounter();
// 参照してる関数(オブジェクト)は別であるため===は一致しない
// 参照している関数(オブジェクト)は別であるため===は一致しない
console.log(countUp === newCountUp);// false
// それぞれの状態も別となる
console.log(countUp()); // => 1
Expand Down