Skip to content
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

feat(operator): 各演算子の解説を追加 #104

Merged
merged 34 commits into from
Jul 30, 2016
Merged
Changes from 1 commit
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
afe0bb1
feat(operator): 草案を追加
azu Jul 25, 2016
00a3b65
feat(operator): 二項演算子の解説を追加
azu Jul 25, 2016
91d434f
feat(operator): グループ演算子についてを追加
azu Jul 25, 2016
c4866af
feat(operator): 単行プラス/マイナス演算子
azu Jul 25, 2016
0ae1f46
feat(operator): 比較演算子を追加
azu Jul 26, 2016
3945b70
style(operator): textlintエラーを修正
azu Jul 26, 2016
c5aed9a
feat(operator): 比較演算子 > < を追加
azu Jul 26, 2016
6141259
feat(operator): ビット演算についてを追加
azu Jul 27, 2016
1207793
style(operator): 表記を統一
azu Jul 27, 2016
4e0bf28
feat(operator): ビット演算子を追加
azu Jul 27, 2016
4df0dab
fix(operator): fix example
azu Jul 27, 2016
8e628d9
fix(operator): fix example
azu Jul 27, 2016
67d0249
fix(operator): fix example code
azu Jul 27, 2016
5bb3d92
feat(operator):条件演算子を追加
azu Jul 28, 2016
24eadff
feat(operator): AND、OR演算子を追加
azu Jul 28, 2016
6290c7f
feat(operator):NOTと文字列結合について
azu Jul 28, 2016
9c03edb
fix(operator): デフォルト引数の記述を変更
azu Jul 28, 2016
ad9a135
fix(operator): update power-doctest for default parameter
azu Jul 29, 2016
3928d00
chore(operator): remove text
azu Jul 29, 2016
4c119a8
chore(operator): 特殊な単項演算子は削除
azu Jul 30, 2016
b06493e
refactor(operator): +演算子の型変換についてを書き換え
azu Jul 30, 2016
9f12c6d
chore(operator): グループ演算子の例を論理演算子に変更
azu Jul 30, 2016
dfc9188
fix(operator): ++と--についてをもっと簡潔に
azu Jul 30, 2016
ef94bd2
style(operator): 無駄なスペースを削除
azu Jul 30, 2016
971ca1c
chore(operator): fix typo
azu Jul 30, 2016
792418a
chore(operator): fix typo
azu Jul 30, 2016
737d784
chore(operator): fix typo
azu Jul 30, 2016
bc07b77
fix(operator): 仕様が何かを明示
azu Jul 30, 2016
91215a7
chore(operator): 口調の統一
azu Jul 30, 2016
a1a7ff5
style(operator): textlintのエラーを修正
azu Jul 30, 2016
7b4df99
chore(operator): indirect callを脚注に移動
azu Jul 30, 2016
a0e6177
chore(operator): 評価結果を返す点についてを追加
azu Jul 30, 2016
06b7c5b
chore(operator): add 。
azu Jul 30, 2016
efec018
chore(test): add timout option
azu Jul 30, 2016
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
19 changes: 13 additions & 6 deletions source/basic/operator/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -735,7 +735,7 @@ console.log(string.length > 0); // => false

グループ演算子は複数の二項演算子が組み合わさった場合に、演算子の優先順序を明示することができる演算子です。

たとえば、次のようにグループ演算子で囲んだ部分が最初に処理されるため、処理結果も変化します
たとえば、次のようにグループ演算子で囲んだ部分が最初に処理されるため、結果も変化します

```js
var a = 1;
Expand All @@ -746,22 +746,29 @@ a + b * c; // 7
```

[演算子の優先順序][]は仕様で定義されていますが、多様な演算子が出てきた場合に見分けるのは難しいです。
そのため、グループ演算子を使い優先順序を明示することが読みやすいコードへとつながります。
グループ演算子はもっとも優先度が高い演算子となります。
そのため、グループ演算子使い優先順序を明示することが読みやすいコードへとつながります。
Copy link
Contributor

Choose a reason for hiding this comment

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

必ずしもそうではないはず

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

そうですね。
https://twitter.com/azu_re/status/759268034276159492
()をなしの例を書こうしてたのが残ってました。
(これは具体的な例に左右されそうなきがするので削除します)


次のようなグループを演算子を使わずに書いたコードを見てみましょう。
`a`が`true`または、`b`かつ`c`が`true`であるときに処理されるif文になっています。

```js
1 * 2 + 3 * 4; // => 14
if (a || b && c) {
// a が true または
// b かつ c が true
}
```

ひとつの式にオペランドが4つ以上出てくると読みにくくなります
ひとつの式に複数の種類の演算子が出てくると読みにくくなる傾向があります
このような場合にはグループ演算子を使い、結合順を明示して書くようにしましょう。

```js
(1 * 2) + (3 * 4); // => 14
if (a || (b && c)) {
// a が true または
// b かつ c が true
}
```


## 文字列演算子(`+`)
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

文字列演算子(+)が唐突感ある(仕様的にはそもそも分かれてるワケではない)
なので、もっと別の位置がいいのかなー

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

暗黙的な変換(次の話)への布石的なものなので後ろにあるといい感じではあるんだけど


数値にでてきたプラス演算子(`+`)は、文字列の結合に利用できます。
Expand Down