Skip to content

Commit 980233b

Browse files
committed
minor edits
1 parent 1e14fa5 commit 980233b

File tree

1 file changed

+9
-16
lines changed

1 file changed

+9
-16
lines changed

README.md

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ fn(); // "Yet more razzling"
198198
```
199199

200200
Also as with a function declaration, if we need to pass arguments to the
201-
function, we would include those in the parentheses.
201+
function, we would include those in the parentheses when we call the function.
202202

203203
We now know how to define a function as a function expression. Very importantly,
204204
***function expressions are not hoisted***. The same is true for any variable
@@ -239,10 +239,10 @@ browser console:
239239

240240
Interestingly, any variables, functions, `Array`s, etc. that are defined
241241
_inside_ of the function expression's body _can't_ be seen _outside_ of the
242-
IIFE. It's like opening up a micro-dimension, a bubble-universe, doing all the
243-
work you could ever want to do there, and then closing the space-time rift.
244-
We'll see some of the practical power of "hiding things" in IIFEs a little
245-
later in this lesson.
242+
IIFE. To see this, check the value of `baseNumber` in the console. It's like
243+
opening up a micro-dimension, a bubble-universe, doing all the work you could
244+
ever want to do there, and then closing the space-time rift. We'll see some of
245+
the practical power of "hiding things" in IIFEs a little later in this lesson.
246246

247247
## Define `Function-Level Scope`
248248

@@ -278,8 +278,8 @@ Let's break this down:
278278
other parameter, `msg`, is set to a default value.
279279
3. Here's our old friend the function expression. It expects two arguments, to
280280
be stored in the parameters `name` and `lang`, and `lang` is assigned the
281-
default value of `"Python"`. The function expression is saved in the local
282-
variable `innerFunction`.
281+
default value of `"Python"`. The function expression itself is saved in the
282+
local variable `innerFunction`.
283283
4. Inside `innerFunction` we make use of its parameters, `name` and `lang`,
284284
***as well as*** the `greeting` and `msg` parameters defined in
285285
innerFunction's containing (parent) function, `outer`. `innerFunction` has
@@ -292,7 +292,7 @@ intuition about scopes: inner things can see their parent outer things.
292292

293293
Note that currently, the values of the arguments being passed to `innerFunction`
294294
are part of the **definition** of `outer`. In order to change those values we
295-
have to modify the `outer` function itself. This is not ideal.
295+
have to modify the `outer` function. This is not ideal.
296296

297297
With a simple change, something miraculous can happen. Rather than having `outer`
298298
return the result of calling `innerFunction`, let's have it return the function
@@ -308,16 +308,9 @@ function outer(greeting, msg="It's a fine day to learn") {
308308
```
309309

310310
The return value of `outer` is now an **anonymous function**. To invoke it, we
311-
update the function call as shown below:
311+
update the function call as follows:
312312

313313
```js
314-
function outer(greeting, msg="It's a fine day to learn") {
315-
const innerFunction = function(name, lang="Python") {
316-
return `${greeting}, ${name}! ${msg} ${lang}`;
317-
}
318-
return innerFunction;
319-
}
320-
321314
outer("Hello")("student", "JavaScript");
322315
//=> "Hello, student! It's a fine day to learn JavaScript"
323316
```

0 commit comments

Comments
 (0)