-
-
Notifications
You must be signed in to change notification settings - Fork 224
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
fix: 「関数とスコープ」における誤字脱字の訂正など #1594
Merged
Merged
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -381,7 +381,7 @@ measureTask(doHeavyTask); | |
|
||
コードの量が増えていくにつれ、人が一度に把握できる量にも限界がやってきます。 | ||
そのため、人が一度に把握できる範囲のサイズに処理をまとめていくことが必要です。 | ||
この問題を解決するアプローチとして、変数の参照できる範囲を小さくすることや処理を関数にまとめるという手法がよく利用されます。 | ||
この問題を解決するアプローチとして、変数を参照できる範囲を小さくすることや処理を関数にまとめるという手法がよく利用されます。 | ||
|
||
## 関数スコープとvarの巻き上げ {#hoisting-var} | ||
|
||
|
@@ -411,7 +411,7 @@ var_x = "varのx"; | |
次に、`let`と`var`で異なる動作を見ていきます。 | ||
|
||
`let`では、変数を**宣言する前**にその変数を参照すると`ReferenceError`の例外が発生して参照できません。 | ||
次のコードでは、変数を宣言する前に、変数`x`を参照したため`ReferenceError`となっています。 | ||
次のコードでは、変数を宣言する前に変数`x`を参照したため`ReferenceError`となっています。 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ここは明確な誤りではないですが、読点が不要であると感じられたため削除しました。 |
||
エラーメッセージから、変数`x`が存在しないからエラーになっているのではなく、実際に宣言した行より前に参照したためエラーとなっているのがわかります。[^1] | ||
|
||
{{book.console}} | ||
|
@@ -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 | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
を を の2重助詞になっていますね。
自分は
の
でも読めるかなーという感じがしています。(音として読んだときに、を
が重なると重たい感じがしてるので、の
にしてる気もしました。厳密な助詞というよりリズムを優先してる感じ。多分の
を飛ばしてもこれは読めるので。)変数が参照できる範囲を だと一番矛盾がないのですが、意味が異なって聞こえる(主語が逆転している感覚がある)
の2つなので、を がかかる位置が増えると 主語が読みにくく感じました。
変数を小さくすること
ではないので。の 以外のやつでいいものがあるといいんですが、おそらく助詞じゃなくて文や単語を少し変えないといけない気がします。
変数のスコープを とか別の単語になる気はしますが、一見して意味がわかる単語は難しいものになる気はしています。(スコープはなんか少し曖昧な感覚)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@azu ありがとうございます。(最初に少し補足しておけばよかったのですが)こちらを変更した理由について説明しますと、確かに「を」が二重になってはしまうのですが、
ため、他と合わせる意味でここを「を」にしていました(あとは単純に、「を」が連続することについて、特に違和感を抱いていませんでした)。
確かに azu さんが言われているように「の」のままとしても日本語ネイティブであれば普通に読めるとは思いますので、戻してもいいかなとも思うのですが、上に書いたように他の箇所では「を」の言い回しが使われているため、一貫性の観点からやはり戻さなくてもいい気もしています(ここを変えるとすると他の箇所も変える必要が生じるように思います)。
すみませんが、以上を踏まえた上でもう一度ご意見をうかがってもよいでしょうか🙏
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
や で並列にしてるのが多分良くないんだと思います。
(を がかかる位置が増えてしまってる)
というのが言いたいことになってる気がするので、並列に並べないように文を直すのが正解かなと思います。
変数を参照できる範囲を小さくすること
の具体が関数にまとめる
なので並列じゃない感じもします。など、文自体を直すのが良いと思います。
ちょっとまだ微妙な文なので、アプローチと具体が逆なのかな
だけの方がスッキリはしますね。
セクションタイトルを強調したいかどうかという別の話になりますが。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ありがとうございます!ここはコラムの最後の段落でありまとめとしての役割もあるため、セクションタイトルを再度強調することに意味があると考え、最後に提示いただいたものをそのまま適用しました。