Commit 444dc0da authored by Caleb C. Sander's avatar Caleb C. Sander
Browse files

Merge branch 'master' into 'master'

Fix typos in callbacks.md

See merge request !1
parents baf236bb 56f8bc88
Showing with 3 additions and 3 deletions
+3 -3
......@@ -134,7 +134,7 @@ setTimeout(() => {
console.log('3 seconds have passed')
}, 3000)
```
The fact that `setTimeout()` is asynchronous means it returns immediately, without witing for the time interval.
The fact that `setTimeout()` is asynchronous means it returns immediately, without waiting for the time interval.
For example, the following code displays `Timeout started` immediately and `Timeout ended` after 1 second:
```js
setTimeout(() => {
......@@ -161,7 +161,7 @@ In general, this requires us to create the next asynchronous event *inside* the
As a concrete example, let's simulate a "random walk" on a grid.
At each step, we randomly move left, right, up, or down, and we count the total number of times we have visited each grid square.
To run an asynchronous action after another one finshes, we *nest it inside the previous callback*.
To run an asynchronous action after another one finishes, we *nest it inside the previous callback*.
Here is a [first attempt](walk1.html) that only moves 3 times.
```js
// ... (the full code is at the link above)
......@@ -226,7 +226,7 @@ walkFrom({row: Math.floor(SIZE / 2), col: Math.floor(SIZE / 2)})
We have seen two examples of asynchronous standard library functions in JavaScript: handling user input and waiting for time.
With both of them, we define a function that we want to get called when something happens.
This structure is common to any asynchronous function; the function passed in to run when it finishes is refered to as the "callback function".
This structure is common to any asynchronous function; the function passed in to run when it finishes is referred to as the "callback function".
It is up to the browser (or Node.js) to ensure that the callbacks we provide get called at the right times.
We have also looked at some of the primary ways to combine asynchronous actions.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment