Skip to content

Commit 85957bc

Browse files
committed
translate "Hidden use of eval" in "Others" to ja
1 parent b054070 commit 85957bc

File tree

1 file changed

+15
-19
lines changed

1 file changed

+15
-19
lines changed

doc/ja/other/timeouts.md

Lines changed: 15 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -76,48 +76,44 @@ JavaScriptは非同期なので、`setTimeout`と`setInterval`関数を使って
7676

7777
ここまでもまだ、任意の数字を与えられた為に影響を受けないタイムアウトがあるかもしれません。しかし、全てのタイムアウトのIDを追跡していく事は推奨されないので、それらは個別にクリアされます。
7878

79-
### Hidden use of `eval`
79+
### 隠された`eval`の使用
8080

81-
`setTimeout` and `setInterval` can also take a string as their first parameter.
82-
This feature should **never** be used, since it internally makes use of `eval`.
81+
`setTimeout``setInterval` は、第一引数に文字列を取る事が可能です。この仕様は内部で`eval`を使用する為に、**絶対に**使うべきではありません。
8382

84-
> **Note:** Since the timeout functions are **not** specified by the ECMAScript
85-
> standard, the exact workings when a string is passed to them might differ in
86-
> various JavaScript implementations. For example, Microsoft's JScript makes use of
87-
> the `Function` constructor in place of `eval`.
83+
> **注意点:** タイムアウト関数はECMAScript標準では制定されて**いない**為に
84+
> 文字列を引数にした場合に厳密な動作は色々なJavaScript実装により異なります。
85+
> 例えば、MicrosoftのJScriptは`eval`の代わりに`Function`コンストラクターを
86+
> 使用します。
8887
8988
function foo() {
90-
// will get called
89+
// この先呼ばれる
9190
}
9291

9392
function bar() {
9493
function foo() {
95-
// never gets called
94+
// 絶対に呼ばれない
9695
}
9796
setTimeout('foo()', 1000);
9897
}
9998
bar();
10099

101-
Since `eval` is not getting called [directly](#core.eval) in this case, the string
102-
passed to `setTimeout` will get executed in the *global scope*; thus, it will
103-
not use the local variable `foo` from the scope of `bar`.
100+
この場合、`eval`[直接](#core.eval)呼ばれないので、文字列が渡された`setTimeout`*global scope*で実行されます。よって、`bar`のスコープから`foo`のローカル変数は使われないのです。
104101

105-
It is further recommended to **not** use a string for passing arguments to the
106-
function that will get called by either of the timeout functions.
102+
さらに、文字列を関数に渡さ**ない**ように推奨される理由として、それぞれのタイムアウト関数から呼び出されるという事があります。
107103

108104
function foo(a, b, c) {}
109105

110-
// NEVER use this
106+
// 絶対にこのように使わない
111107
setTimeout('foo(1,2, 3)', 1000)
112108

113-
// Instead use an anonymous function
109+
// 匿名関数を代わりに使用する
114110
setTimeout(function() {
115111
foo(a, b, c);
116112
}, 1000)
117113

118-
> **Note:** While it is also possible to use the syntax
119-
> `setTimeout(foo, 1000, a, b, c)`, it is not recommended, as its use may lead
120-
> to subtle errors when used with [methods](#function.this).
114+
> **注意点:** `setTimeout(foo, 1000, a, b, c)`のようなシンタックスを使用する事も
115+
> できますが、[メソッド](#function.this)を使用した際に、分かりにくいエラーが起りえるので
116+
> 使用はお勧めしません。
121117
122118
### In Conclusion
123119

0 commit comments

Comments
 (0)