@@ -19,7 +19,7 @@ gets executed might block the thread, it is by **no means** a safe bet that one
19
19
will get the exact delay that was specified in the ` setTimeout ` call.
20
20
21
21
The function that was passed as the first parameter will get called by the
22
- * global object* , that means, that [ ` this ` ] ( #function.this ) inside the called function
22
+ * global object* , which means that [ ` this ` ] ( #function.this ) inside the called function
23
23
refers to that very object.
24
24
25
25
function Foo() {
@@ -42,7 +42,7 @@ refers to that very object.
42
42
### Stacking Calls with ` setInterval `
43
43
44
44
While ` setTimeout ` only runs the function once, ` setInterval ` - as the name
45
- suggests - will execute the function ** every** ` X ` milliseconds. But its use is
45
+ suggests - will execute the function ** every** ` X ` milliseconds, but its use is
46
46
discouraged.
47
47
48
48
When code that is being executed blocks the timeout call, ` setInterval ` will
@@ -54,15 +54,15 @@ intervals, result in function calls stacking up.
54
54
}
55
55
setInterval(foo, 100);
56
56
57
- In the above code ` foo ` will get called once and will then block for one second.
57
+ In the above code, ` foo ` will get called once and will then block for one second.
58
58
59
- While ` foo ` blocks the code ` setInterval ` will still schedule further calls to
59
+ While ` foo ` blocks the code, ` setInterval ` will still schedule further calls to
60
60
it. Now, when ` foo ` has finished, there will already be ** ten** further calls to
61
61
it waiting for execution.
62
62
63
63
### Dealing with Possible Blocking Code
64
64
65
- The easiest as well as most controllable solution, is to use ` setTimeout ` within
65
+ The easiest solution, as well as most controllable solution, is to use ` setTimeout ` within
66
66
the function itself.
67
67
68
68
function foo(){
@@ -72,7 +72,7 @@ the function itself.
72
72
foo();
73
73
74
74
Not only does this encapsulate the ` setTimeout ` call, but it also prevents the
75
- stacking of calls and it gives additional control.` foo ` itself can now decide
75
+ stacking of calls and it gives additional control. ` foo ` itself can now decide
76
76
whether it wants to run again or not.
77
77
78
78
### Manually Clearing Timeouts
@@ -86,7 +86,7 @@ the first place.
86
86
87
87
### Clearing all timeouts
88
88
89
- As there is no built-in method for clearing all timeouts and/or intervals,
89
+ Because there is no built-in method for clearing all timeouts and/or intervals,
90
90
it is necessary to use brute force in order to achieve this functionality.
91
91
92
92
// clear "all" timeouts
@@ -101,7 +101,7 @@ they can be cleared specifically.
101
101
### Hidden use of ` eval `
102
102
103
103
` setTimeout ` and ` setInterval ` can also take a string as their first parameter.
104
- This feature should ** never** be used, since it internally makes use of ` eval ` .
104
+ This feature should ** never** be used because it internally makes use of ` eval ` .
105
105
106
106
> ** Note:** Since the timeout functions are ** not** specified by the ECMAScript
107
107
> standard, the exact workings when a string is passed to them might differ in
@@ -148,7 +148,7 @@ function that will get called by either of the timeout functions.
148
148
to be supplied to the function that gets called. An * anonymous function* should
149
149
be passed that then takes care of the actual call.
150
150
151
- Further , the use of ` setInterval ` should be avoided since its scheduler is not
151
+ Furthermore , the use of ` setInterval ` should be avoided because its scheduler is not
152
152
blocked by executing JavaScript.
153
153
154
154
[ 1 ] : http://en.wikipedia.org/wiki/Document_Object_Model " Document Object Model "
0 commit comments