Skip to content

Commit 043fb9f

Browse files
committed
Add index terms to Chapter 14
1 parent 76016c0 commit 043fb9f

File tree

9 files changed

+527
-454
lines changed

9 files changed

+527
-454
lines changed

03_functions.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ cause the function to return `undefined`.
9898
initial values are given by the _caller_ of the function, not the code
9999
in the function itself.
100100

101-
(((function,scope)))(((scope)))(((variable,local)))An
101+
(((function,scope)))(((scope)))(((local variable)))An
102102
important property of functions is that the variables created inside
103103
of them, including their parameters, are _local_ to the function. This
104104
means, for example, that the `result` variable in the `power` example
@@ -454,7 +454,7 @@ console.log("R", 2, "D", 2);
454454

455455
== Closure ==
456456

457-
(((call stack)))(((variable,local)))(((function,as
457+
(((call stack)))(((local variable)))(((function,as
458458
value)))(((closure)))(((scope)))The ability to treat functions as
459459
values, combined with the fact that local variables are “re-created”
460460
every time a function is called, brings up an interesting question.
@@ -1028,7 +1028,7 @@ current position is the same as the one the function is looking for,
10281028
it adds 1 to a counter variable. Once the loop has finished, the
10291029
counter can be returned.
10301030

1031-
(((variable,local)))Take care to make all the variables used in the
1031+
(((local variable)))Take care to make all the variables used in the
10321032
function _local_ to the function by using the `var` keyword.
10331033

10341034
!!solution!!

05_higher_order.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ the body is inside of the function value, as well as inside of the
195195
((parentheses)) of the call to `forEach`. This is why it has to be
196196
closed with the closing brace _and_ closing parenthesis.
197197

198-
(((variable,local)))(((parameters)))Using this pattern, we can
198+
(((local variable)))(((parameters)))Using this pattern, we can
199199
specify a variable name for the current element (`number`), rather
200200
than having to pick it out of the array manually.
201201

@@ -305,7 +305,7 @@ repeat(3, function(n) {
305305
----
306306

307307
(((inner function)))(((nesting,of functions)))((({}
308-
(block))))(((variable,local)))(((closure)))The ((lexical scoping))
308+
(block))))(((local variable)))(((closure)))The ((lexical scoping))
309309
rules that we discussed in link:03_functions.html#scoping[Chapter 3]
310310
work to our advantage when using functions in this way. In the example
311311
above, the `n` variable is a ((parameter)) to the outer function.

10_modules.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -776,7 +776,7 @@ function with their interfaces as arguments.
776776

777777
=== Month names ===
778778

779-
(((Date type)))(((weekday example)))(((month name exercise)))Write a
779+
(((Date type)))(((weekday example)))(((month name (exercise))))Write a
780780
simple module similar to the `weekDay` module, which can convert month
781781
numbers (zero-based, as in the `Date` type) to names, and names back
782782
to numbers. Give it its own namespace, since it will need an internal
@@ -800,7 +800,7 @@ endif::html_target[]
800800

801801
!!solution!!
802802

803-
(((month name exercise)))This follows the `weekDay` module almost
803+
(((month name (exercise))))This follows the `weekDay` module almost
804804
exactly. A function expression, called immediately, wraps the variable
805805
that holds the array of names, along with the two functions that must
806806
be exported. The functions are put in an object, and returned. The

11_language.txt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -81,10 +81,10 @@ are normal variables in this language, applied just like other
8181
need a `do` construct (like above) to represent doing multiple things
8282
in sequence.
8383

84-
(((parsing)))The ((data structure)) the parser will use to describe a
85-
program will consist of ((expression)) objects, each of which has a
86-
`type` property indicating the kind of expression it is and other
87-
properties to describe its content.
84+
(((type property)))(((parsing)))The ((data structure)) the parser will
85+
use to describe a program will consist of ((expression)) objects, each
86+
of which has a `type` property indicating the kind of expression it is
87+
and other properties to describe its content.
8888

8989
(((identifier)))Expresions of type `"value"` represent literal strings
9090
or numbers. Their `value` property contains the string or number value
@@ -812,7 +812,7 @@ how many characters to slice off.
812812
assign a ((variable)) a value is `define`. This construct acts both as
813813
a way to define new variables and to give existing ones a new value.
814814

815-
(((variable,local)))This ((ambiguity)) causes a problem. When you try
815+
(((local variable)))This ((ambiguity)) causes a problem. When you try
816816
to give a non-local variable a new value, you will end up defining a
817817
local one with the same name instead. (Some languages work like this
818818
by design, but I've always found it a silly way to handle ((scope)).)

12_browser.txt

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -323,12 +323,13 @@ also have used `"`, but that'd make the program harder to read.
323323

324324
== In the sandbox ==
325325

326-
(((World Wide Web)))(((browser)))(((website)))(((security)))Running
327-
programs downloaded from the ((Internet)) is potentially dangerous.
328-
You do not know much about the people behind most sites you visit, and
329-
they do not necessarily mean well. Running programs by people who do
330-
not mean well is how you get your computer infected by ((virus))es,
331-
your data stolen, and your accounts hacked.
326+
((malicious script))(((World Wide
327+
Web)))(((browser)))(((website)))(((security)))Running programs
328+
downloaded from the ((Internet)) is potentially dangerous. You do not
329+
know much about the people behind most sites you visit, and they do
330+
not necessarily mean well. Running programs by people who do not mean
331+
well is how you get your computer infected by ((virus))es, your data
332+
stolen, and your accounts hacked.
332333

333334
Yet the attraction of the Web is that you can surf it without
334335
necessarily ((trust))ing all the pages you visit. This is why browsers

13_dom.txt

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -97,13 +97,13 @@ node is `document.body`. Some of these children can be ((leaf node))s,
9797
such as pieces of ((text)) or ((comment))s (which are written between
9898
`<!--` and `-->` in HTML).
9999

100-
(((ELEMENT_NODE code)))(((COMMENT_NODE code)))(((TEXT_NODE
101-
code)))(((nodeType property)))Each DOM node object has a `nodeType`
102-
property, which contains a numeric code that identifies the type of
103-
node. Regular elements have the value 1, which is also defined as the
104-
constant property `document.ELEMENT_NODE`. Text nodes, representing a
105-
section of text in the document, have the value 3
106-
(`document.TEXT_NODE`). Comments get the value 8
100+
(((text node)))(((ELEMENT_NODE code)))(((COMMENT_NODE
101+
code)))(((TEXT_NODE code)))(((nodeType property)))Each DOM node object
102+
has a `nodeType` property, which contains a numeric code that
103+
identifies the type of node. Regular elements have the value 1, which
104+
is also defined as the constant property `document.ELEMENT_NODE`. Text
105+
nodes, representing a section of text in the document, have the value
106+
3 (`document.TEXT_NODE`). Comments get the value 8
107107
(`document.COMMENT_NODE`).
108108

109109
So another way to visualize our document ((tree)) is:
@@ -178,7 +178,7 @@ will be null, and for a last child, `nextSibling` is null.
178178

179179
(((talksAbout function)))(((recursion)))(((nesting,of objects)))When
180180
dealing with a nested data structure like this, recursive functions
181-
are often useful. The one below scans a document for text nodes
181+
are often useful. The one below scans a document for ((text node))s
182182
containing a given string, and returns `true` when it has found one.
183183

184184
[[talksAbout]]
@@ -328,9 +328,9 @@ but adding a new text node to replace them. For this, we use the
328328
</script>
329329
----
330330

331-
Given a string, `createTextNode` gives us a type 3 DOM node (a text
332-
node), which we can insert into the document to make it show up on the
333-
screen.
331+
(((text node)))Given a string, `createTextNode` gives us a type 3 DOM
332+
node (a text node), which we can insert into the document to make it
333+
show up on the screen.
334334

335335
(((live data structure)))(((getElementsByTagName
336336
method)))(((childNodes property)))The loop that goes over the images
@@ -475,10 +475,11 @@ the node. We loop over all matches of the keyword expression,
475475
appending the text _between_ them as regular text nodes, and the text
476476
matched as text nodes wrapped in `<strong>` (bold) elements.
477477

478-
(((getElementsByTagName method)))We can automatically highlight all
479-
programs on the page by looping over all the `<pre>` elements that
480-
have a `data-language` attribute, and calling `highlightCode` on each
481-
one with the correct regular expression for the language.
478+
(((data attribute)))(((getElementsByTagName method)))We can
479+
automatically highlight all programs on the page by looping over all
480+
the `<pre>` elements that have a `data-language` attribute, and
481+
calling `highlightCode` on each one with the correct regular
482+
expression for the language.
482483

483484
// include_code
484485

@@ -1134,7 +1135,7 @@ a recursive call on it to inspect its own children.
11341135

11351136
=== The cat's hat ===
11361137

1137-
(((cat's hat exercise)))Extend the cat ((animation)) defined
1138+
(((cat's hat (exercise))))Extend the cat ((animation)) defined
11381139
link:13_dom.html#animation[earlier] so that both the cat and his hat
11391140
(`<img src="img/hat.png">`) orbit, at opposite sides of the ellipse.
11401141

0 commit comments

Comments
 (0)