Skip to content

Commit 30d2c58

Browse files
committed
fox repo
1 parent dccbcfd commit 30d2c58

File tree

1 file changed

+9
-10
lines changed

1 file changed

+9
-10
lines changed

doc/zhtw/other/timeouts.md

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@
7373
clearTimeout(i);
7474
}
7575

76-
可能還有一些定石器不會在上面的代碼中被清除,因此我們可以事先保存所有的定時器 ID,然後一把清除。
76+
可能還有一些定時器不會在上面的代碼中被清除,因此我們可以事先保存所有的定時器 ID,然後一把清除。
7777

7878

7979
// clear "all" timeouts
@@ -105,15 +105,15 @@ This feature should **never** be used because it internally makes use of `eval`.
105105
}
106106
bar();
107107

108-
Since `eval` is not getting called [directly](#core.eval) in this case, the string
109-
passed to `setTimeout` will be executed in the *global scope*; thus, it will
108+
Since `eval` is not getting called [directly](#core.eval) in this case, the string
109+
passed to `setTimeout` will be executed in the *global scope*; thus, it will
110110
not use the local variable `foo` from the scope of `bar`.
111111

112112
It is further recommended to **not** use a string to pass arguments to the
113-
function that will get called by either of the timeout functions.
113+
function that will get called by either of the timeout functions.
114114

115115
function foo(a, b, c) {}
116-
116+
117117
// NEVER use this
118118
setTimeout('foo(1, 2, 3)', 1000)
119119

@@ -122,19 +122,18 @@ function that will get called by either of the timeout functions.
122122
foo(a, b, c);
123123
}, 1000)
124124

125-
> **Note:** While it is also possible to use the syntax
125+
> **Note:** While it is also possible to use the syntax
126126
> `setTimeout(foo, 1000, a, b, c)`, it is not recommended, as its use may lead
127-
> to subtle errors when used with [methods](#function.this).
127+
> to subtle errors when used with [methods](#function.this).
128128
129129
### In Conclusion
130130

131-
A string should **never** be used as the parameter of `setTimeout` or
132-
`setInterval`. It is a clear sign of **really** bad code, when arguments need
131+
A string should **never** be used as the parameter of `setTimeout` or
132+
`setInterval`. It is a clear sign of **really** bad code, when arguments need
133133
to be supplied to the function that gets called. An *anonymous function* should
134134
be passed that then takes care of the actual call.
135135

136136
Furthermore, the use of `setInterval` should be avoided because its scheduler is not
137137
blocked by executing JavaScript.
138138

139139
[1]: http://en.wikipedia.org/wiki/Document_Object_Model "Document Object Model"
140-

0 commit comments

Comments
 (0)