3
3
Since JavaScript is asynchronous, it is possible to schedule the execution of a
4
4
function using the ` setTimeout ` and ` setInterval ` functions.
5
5
6
- > ** Note:** Timeouts are ** not** part of the ECMAScript Standard. They are
7
- > implemented as part of the [ DOM] [ 1 ] .
6
+ > ** Note:** Timeouts are ** not** part of the ECMAScript standard. They were
7
+ > implemented in [ BOM, or DOM Level 0] [ 1 ] , which are never defined nor
8
+ > documented formally. No recommended specification has been published so far,
9
+ > however, they are currently being standardized by [ HTML5] [ 2 ] . Due to this
10
+ > nature, the implementation may vary from browsers and engines.
8
11
9
12
function foo() {}
10
13
var id = setTimeout(foo, 1000); // returns a Number > 0
@@ -115,8 +118,7 @@ specifically.
115
118
` setTimeout ` and ` setInterval ` can also take a string as their first parameter.
116
119
This feature should ** never** be used because it internally makes use of ` eval ` .
117
120
118
- > ** Note:** Since the timeout functions are ** not** specified by the ECMAScript
119
- > standard, the exact workings when a string is passed to them might differ in
121
+ > ** Note:** The exact workings when a string is passed to them might differ in
120
122
> various JavaScript implementations. For example, Microsoft's JScript uses
121
123
> the ` Function ` constructor in place of ` eval ` .
122
124
@@ -149,9 +151,11 @@ function that will get called by either of the timeout functions.
149
151
foo(a, b, c);
150
152
}, 1000)
151
153
152
- > ** Note:** While it is also possible to use the syntax
153
- > ` setTimeout(foo, 1000, a, b, c) ` , it is not recommended, as its use may lead
154
- > to subtle errors when used with [ methods] ( #function.this ) .
154
+ > ** Note:** While it is also possible to use ` setTimeout(foo, 1000, a, b, c) `
155
+ > syntax, it is not recommended, as its use may lead
156
+ > to subtle errors when used with [ methods] ( #function.this ) .
157
+ > Furthermore, the syntax might not work in some JavaScript implementations.
158
+ > For example, Microsoft's Internet Explorer [ does ** not** pass the arguments directly to the callback] ( 3 ) .
155
159
156
160
### In Conclusion
157
161
@@ -163,5 +167,6 @@ be passed that then takes care of the actual call.
163
167
Furthermore, the use of ` setInterval ` should be avoided because its scheduler is not
164
168
blocked by executing JavaScript.
165
169
166
- [ 1 ] : http://en.wikipedia.org/wiki/Document_Object_Model " Document Object Model "
167
-
170
+ [ 1 ] : http://www.nczonline.net/blog/2009/09/29/web-definitions-dom-ajax-and-more/ " Web definitions: DOM, Ajax, and more "
171
+ [ 2 ] : http://www.w3.org/TR/2014/WD-html5-20140617/webappapis.html#timers " 6 Web application APIs - HTML5 "
172
+ [ 3 ] : http://msdn.microsoft.com/en-us/library/ie/ms536753(v=vs.85).aspx " setTimeout method (Internet Explorer) "
0 commit comments