Skip to content

Commit ce16685

Browse files
committed
translate "Avoiding the Reference Problem" in "Function" to ja
1 parent 860f7c2 commit ce16685

1 file changed

Lines changed: 5 additions & 10 deletions

File tree

‎doc/ja/function/closures.md‎

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,9 @@ JavaScriptでは、スコープ自体を参照・代入する事が出来無い
5050

5151
期待した動作をする為には、`i`の値の**コピー**を作る必要があります。
5252

53-
### Avoiding the Reference Problem
53+
### 参照問題を回避するには
5454

55-
In order to copy the value of the loop's index variable, it is best to use an
56-
[anonymous wrapper](#function.scopes).
55+
ループのインデックス変数をコピーする為には、[匿名ラッパー](#function.scopes)を使うのがベストです。
5756

5857
for(var i = 0; i < 10; i++) {
5958
(function(e) {
@@ -63,15 +62,11 @@ In order to copy the value of the loop's index variable, it is best to use an
6362
})(i);
6463
}
6564

66-
The anonymous outer function gets called immediately with `i` as its first
67-
argument and will receive a copy of the **value** of `i` as its parameter `e`.
65+
外部の匿名関数は`i`を即座に第一引数として呼び出し、引数`e`を`i`の**値**のコピーとして受け取ります。
6866

69-
The anonymous function that gets passed to `setTimeout` now has a reference to
70-
`e`, whose value does **not** get changed by the loop.
67+
`e`を参照している`setTimeout`を受け取った匿名関数はループによって値が変わる事が**ありません**。
7168

72-
There is another possible way of achieving this; that is to return a function
73-
from the anonymous wrapper, that will then have the same behavior as the code
74-
above.
69+
他にこのような事を実現する方法があります。それは匿名ラッパーから関数を返してあげる事です。これは上記のコードと同じような効果があります。
7570

7671
for(var i = 0; i < 10; i++) {
7772
setTimeout((function(e) {

0 commit comments

Comments
 (0)