Skip to content

Commit eb69678

Browse files
committed
[WIP]
1 parent 1d3502a commit eb69678

File tree

1 file changed

+57
-3
lines changed

1 file changed

+57
-3
lines changed

README.md

Lines changed: 57 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,12 +83,13 @@
8383

8484
**[⬆ ページのTopへ戻る](#table-of-contents)**
8585

86-
## 参照(References) -> 変数??
86+
## 参照(References)
8787

8888
- [2.1](#2.1) <a name='2.1'></a> Use `const` for all of your references; avoid using `var`.
8989
- [2.1](#2.1) <a name='2.1'></a> すべての参照は `const` を使用し、`var` を使用しないでください。
9090

9191
> Why? This ensures that you can't reassign your references, which can lead to bugs and difficult to comprehend code.
92+
9293
> なぜ? This ensures that you can't reassign your references, which can lead to bugs and difficult to comprehend code.
9394

9495
```javascript
@@ -106,6 +107,8 @@
106107

107108
> Why? `let` is block-scoped rather than function-scoped like `var`.
108109

110+
> なぜ? 関数スコープの `var` よりむしろ、ブロックスコープの `let`
111+
109112
```javascript
110113
// bad
111114
var count = 1;
@@ -189,9 +192,12 @@
189192

190193
<a name="es6-computed-properties"></a>
191194
- [3.4](#3.4) <a name='3.4'></a> Use computed property names when creating objects with dynamic property names.
195+
- [3.4](#3.4) <a name='3.4'></a> 動的にプロパティ名を持つオブジェクトを作成する場合、計算されたプロパティ名(computed property names)を利用してください。
192196

193197
> Why? They allow you to define all the properties of an object in one place.
194198

199+
> なぜ? こうすることで、オブジェクトのプロパティを1箇所で定義することができます。
200+
195201
```javascript
196202
197203
function getKey(k) {
@@ -215,6 +221,7 @@
215221

216222
<a name="es6-object-shorthand"></a>
217223
- [3.5](#3.5) <a name='3.5'></a> Use object method shorthand.
224+
- [3.5](#3.5) <a name='3.5'></a> メソッドの短縮構文を利用してください。
218225

219226
```javascript
220227
// bad
@@ -238,9 +245,12 @@
238245

239246
<a name="es6-object-concise"></a>
240247
- [3.6](#3.6) <a name='3.6'></a> Use property value shorthand.
248+
- [3.6](#3.6) <a name='3.6'></a> プロパティの短縮構文を利用してください。
241249

242250
> Why? It is shorter to write and descriptive.
243251

252+
> Why? 記述や説明が簡潔になるからです。
253+
244254
```javascript
245255
const lukeSkywalker = 'Luke Skywalker';
246256
@@ -256,9 +266,12 @@
256266
```
257267

258268
- [3.7](#3.7) <a name='3.7'></a> Group your shorthand properties at the beginning of your object declaration.
269+
- [3.7](#3.7) <a name='3.7'></a> プロパティの短縮構文はオブジェクト宣言の先頭にまとめてください。
259270

260271
> Why? It's easier to tell which properties are using the shorthand.
261272
273+
> なぜ? どのプロパティが短縮構文を利用しているか分かりやすいからです。
274+
262275
```javascript
263276
const anakinSkywalker = 'Anakin Skywalker';
264277
const lukeSkywalker = 'Luke Skywalker';
@@ -396,19 +409,23 @@
396409
// bad
397410
function processInput(input) {
398411
// then a miracle occurs
412+
// その後、奇跡が起こります。
399413
return [left, right, top, bottom];
400414
}
401415
402416
// the caller needs to think about the order of return data
417+
// 呼び出し者で返却されるデータの順番を考慮する必要があります。
403418
const [left, __, top] = processInput(input);
404419
405420
// good
406421
function processInput(input) {
407422
// then a miracle occurs
423+
// その後、奇跡が起こります。
408424
return { left, right, top, bottom };
409425
}
410426
411427
// the caller selects only the data they need
428+
// 呼び出し元は必要なデータのみ選択すればいい。
412429
const { left, right } = processInput(input);
413430
```
414431
@@ -482,9 +499,12 @@
482499
## 関数(Functions)
483500
484501
- [7.1](#7.1) <a name='7.1'></a> Use function declarations instead of function expressions.
502+
- [7.1](#7.1) <a name='7.1'></a> 関数式より関数宣言を利用してください。
485503
486504
> Why? Function declarations are named, so they're easier to identify in call stacks. Also, the whole body of a function declaration is hoisted, whereas only the reference of a function expression is hoisted. This rule makes it possible to always use [Arrow Functions](#arrow-functions) in place of function expressions.
487505

506+
> なぜ? Function declarations are named, so they're easier to identify in call stacks. Also, the whole body of a function declaration is hoisted, whereas only the reference of a function expression is hoisted. This rule makes it possible to always use [Arrow Functions](#arrow-functions) in place of function expressions.
507+
488508
```javascript
489509
// bad
490510
const foo = function () {
@@ -676,11 +696,16 @@
676696
```
677697
678698
- [8.2](#8.2) <a name='8.2'></a> If the function body consists of a single expression, feel free to omit the braces and use the implicit return. Otherwise use a `return` statement.
699+
- [8.2](#8.2) <a name='8.2'></a> 関数の本体が1つの式で構成されている場合は、中括弧({})を省略し、暗黙のreturnを利用することができます。それ以外は `return` 文を利用してください。
679700
680701
> Why? Syntactic sugar. It reads well when multiple functions are chained together.
681702
703+
> なぜ? 糖衣構文(読みやすさのために導入される構文)だからです。複数の関数が連結される場合に読みやすくなります。
704+
682705
> Why not? If you plan on returning an object.
683706
707+
> 使うべきではない? オブジェクトを返す場合は。
708+
684709
```javascript
685710
// good
686711
[1, 2, 3].map(number => `A string containing the ${number}.`);
@@ -699,9 +724,12 @@
699724
```
700725
701726
- [8.3](#8.3) <a name='8.3'></a> In case the expression spans over multiple lines, wrap it in parentheses for better readability.
727+
- [8.3](#8.3) <a name='8.3'></a> 式の全長が複数行にまたがる場合は、可読性をより良くするため丸括弧()で囲ってください。
702728
703729
> Why? It shows clearly where the function starts and ends.
704730
731+
> なぜ? 関数の開始と終了部分が分かりやすく見えるためです。
732+
705733
```js
706734
// bad
707735
[1, 2, 3].map(number => 'As time went by, the string containing the ' +
@@ -718,9 +746,12 @@
718746
719747
720748
- [8.4](#8.4) <a name='8.4'></a> If your function only takes a single argument, feel free to omit the parentheses.
749+
- [8.4](#8.4) <a name='8.4'></a> 関数の引数が1つの場合、丸括弧()を省略することができます。
721750
722751
> Why? Less visual clutter.
723752
753+
> なぜ? あまり見難くないからです。
754+
724755
```js
725756
// good
726757
[1, 2, 3].map(x => x * x);
@@ -855,7 +886,7 @@
855886
## モジュール(Modules)
856887
857888
- [10.1](#10.1) <a name='10.1'></a> Always use modules (`import`/`export`) over a non-standard module system. You can always transpile to your preferred module system.
858-
- [10.1](#10.1) <a name='10.1'></a> Always use modules (`import`/`export`) over a non-standard module system. You can always transpile to your preferred module system.
889+
- [10.1](#10.1) <a name='10.1'></a> 非標準のモジュールシステムではなく、常に (`import`/`export`) を利用してください。こうすることで好みのモジュールシステムへいつでもトランスパイルすることでできます。
859890
860891
> Why? Modules are the future, let's start using the future now.
861892
@@ -910,12 +941,15 @@
910941
911942
**[⬆ ページのTopへ戻る](#table-of-contents)**
912943
913-
## Iterators and Generators
944+
## イテレータとジェネレータ(Iterators and Generators)
914945
915946
- [11.1](#11.1) <a name='11.1'></a> Don't use iterators. Prefer JavaScript's higher-order functions like `map()` and `reduce()` instead of loops like `for-of`.
947+
- [11.1](#11.1) <a name='11.1'></a> iteratorsを利用しないでください。`for-of` ループの代わりに `map()``reduce()` のようなJavascriptの高級関数(higher-order functions)を利用してください。
916948
917949
> Why? This enforces our immutable rule. Dealing with pure functions that return values is easier to reason about than side-effects.
918950
951+
> なぜ? これはimmutable(不変)ルールを適用します。値を返ような関数の中身の処理を気にするより副作用について推測するほうが簡単です。
952+
919953
```javascript
920954
const numbers = [1, 2, 3, 4, 5];
921955

@@ -938,9 +972,12 @@
938972
```
939973
940974
- [11.2](#11.2) <a name='11.2'></a> Don't use generators for now.
975+
- [11.2](#11.2) <a name='11.2'></a> 現時点ではgeneratorsは利用しないでください。
941976
942977
> Why? They don't transpile well to ES5.
943978
979+
> なぜ? ES5にうまくトランスパイルできないから。
980+
944981
**[⬆ ページのTopへ戻る](#table-of-contents)**
945982
946983
@@ -1020,9 +1057,12 @@
10201057
```
10211058
10221059
- [13.3](#13.3) <a name='13.3'></a> Group all your `const`s and then group all your `let`s.
1060+
- [13.3](#13.3) <a name='13.3'></a> まず `const` をグループ化して、その後 `let` をグループ化してください。
10231061
10241062
> Why? This is helpful when later on you might need to assign a variable depending on one of the previous assigned variables.
10251063
1064+
> なぜ? 以前に割り当てた変数に応じて、後で新しい変数を追加する場合に有用だからです。
1065+
10261066
```javascript
10271067
// bad
10281068
let i, len, dragonball,
@@ -1045,9 +1085,12 @@
10451085
```
10461086
10471087
- [13.4](#13.4) <a name='13.4'></a> Assign variables where you need them, but place them in a reasonable place.
1088+
- [13.4](#13.4) <a name='13.4'></a> 変数を割り当てる際は、必要かつ合理的な場所で行ってください。
10481089
10491090
> Why? `let` and `const` are block scoped and not function scoped.
10501091
1092+
> なぜ? `let` と `const` はブロックスコープだからです。関数スコープではありません。
1093+
10511094
```javascript
10521095
// good
10531096
function() {
@@ -1539,6 +1582,7 @@
15391582
15401583
- [18.6](#18.6) <a name='18.6'></a> Use indentation when making long method chains. Use a leading dot, which
15411584
emphasizes that the line is a method call, not a new statement.
1585+
- [18.6](#18.6) <a name='18.6'></a> 長くメソッドを連結する場合はインデントを利用してください。行がメソッド呼び出しではなく、新しい文であることを強調するために先頭にドット(.)を配置してください。
15421586
15431587
```javascript
15441588
// bad
@@ -1578,6 +1622,7 @@
15781622
```
15791623
15801624
- [18.7](#18.7) <a name='18.7'></a> Leave a blank line after blocks and before the next statement.
1625+
- [18.7](#18.7) <a name='18.7'></a> 文の前とブロックの後には改行を残してください。
15811626
15821627
```javascript
15831628
// bad
@@ -1635,6 +1680,7 @@
16351680
```
16361681
16371682
- [18.8](#18.8) <a name='18.8'></a> Do not pad your blocks with blank lines.
1683+
- [18.8](#18.8) <a name='18.8'></a> ブロックに空行を挟み込まないでください。
16381684
16391685
```javascript
16401686
// bad
@@ -1667,6 +1713,7 @@
16671713
```
16681714
16691715
- [18.9](#18.9) <a name='18.9'></a> Do not add spaces inside parentheses.
1716+
- [18.9](#18.9) <a name='18.9'></a> 丸括弧()の内側にスペースを追加しないでください。
16701717
16711718
```javascript
16721719
// bad
@@ -1691,6 +1738,7 @@
16911738
```
16921739
16931740
- [18.10](#18.10) <a name='18.10'></a> Do not add spaces inside brackets.
1741+
- [18.10](#18.10) <a name='18.10'></a> 角括弧([])の内側にスペースを追加しないでください。
16941742
16951743
```javascript
16961744
// bad
@@ -1703,6 +1751,7 @@
17031751
```
17041752
17051753
- [18.11](#18.11) <a name='18.11'></a> Add spaces inside curly braces.
1754+
- [18.11](#18.11) <a name='18.11'></a> 中括弧({})の内側にスペースを追加しないでください。
17061755
17071756
```javascript
17081757
// bad
@@ -1756,6 +1805,8 @@
17561805
17571806
> Why? This leads to cleaner git diffs. Also, transpilers like Babel will remove the additional trailing comma in the transpiled code which means you don't have to worry about the [trailing comma problem](es5/README.md#commas) in legacy browsers.
17581807
1808+
> なぜ? これはクリーンなgitの差分につながります。また、Babelの様なトランスパイラはトランスパイルする際に末尾の余計なカンマを除去します。これは、レガシーブラウザでの[余計なカンマ問題](es5/README.md#commas)を心配する必要がないことを意味します。
1809+
17591810
```javascript
17601811
// bad - git diff without trailing comma
17611812
const hero = {
@@ -2014,6 +2065,7 @@
20142065
```
20152066
20162067
- [22.6](#22.6) <a name='22.6'></a> If your file exports a single class, your filename should be exactly the name of the class.
2068+
- [22.6](#22.6) <a name='22.6'></a> ファイルを1つのクラスとしてexportする場合、ファイル名はクラス名と完全に一致させなければなりません。
20172069
20182070
```javascript
20192071
// file contents
@@ -2034,6 +2086,7 @@
20342086
```
20352087
20362088
- [22.7](#22.7) <a name='22.7'></a> Use camelCase when you export-default a function. Your filename should be identical to your function's name.
2089+
- [22.7](#22.7) <a name='22.7'></a> Default exportが関数の場合、キャメルケース(小文字から始まる)を利用してください。ファイル名は関数名と同じにしなければなりません。
20372090
20382091
```javascript
20392092
function makeStyleGuide() {
@@ -2043,6 +2096,7 @@
20432096
```
20442097
20452098
- [22.8](#22.8) <a name='22.8'></a> Use PascalCase when you export a singleton / function library / bare object.
2099+
- [22.8](#22.8) <a name='22.8'></a> シングルトン / function library / 単なるオブジェクトをexportする場合、パスカルケース(大文字から始まる)を利用してください。
20462100
20472101
```javascript
20482102
const AirbnbStyleGuide = {

0 commit comments

Comments
 (0)