Skip to content

Commit b23d868

Browse files
committed
Fix and clean up index terms
1 parent 043fb9f commit b23d868

22 files changed

Lines changed: 470 additions & 451 deletions

00_intro.txt

Lines changed: 24 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,12 @@ appeal to our sense of the physical world, and build interfaces that
1818
mimic that world, and allow us to manipulate shapes on a screen with
1919
our fingers. This works very well for casual machine interaction.
2020

21-
(((programming language)))(((machine language)))But we have not yet
22-
found a good way to use the point-and-click approach to communicate
23-
things to the computer that the designer of the interface did not
24-
anticipate. For open-ended interfaces, such as instructing the
25-
computer to perform arbitrary tasks, we've had more luck with an
26-
approach that makes use of our talent for language: teaching the
27-
machine a language.
21+
(((programming language)))But we have not yet found a good way to use
22+
the point-and-click approach to communicate things to the computer
23+
that the designer of the interface did not anticipate. For open-ended
24+
interfaces, such as instructing the computer to perform arbitrary
25+
tasks, we've had more luck with an approach that makes use of our
26+
talent for language: teaching the machine a language.
2827

2928
(((human language)))(((expressivity)))Human languages allow words and
3029
subsentences to be combined in many, many ways, allowing us to say
@@ -133,9 +132,9 @@ their craft.
133132

134133
== Why language matters ==
135134

136-
(((programming language)))(((binary)))In the beginning, at the birth
137-
of computing, there were no programming languages. Programs looked
138-
something like this:
135+
(((programming language)))(((machine code)))(((binary data)))In the
136+
beginning, at the birth of computing, there were no programming
137+
languages. Programs looked something like this:
139138

140139
----
141140
00110001 00000000 00000000
@@ -263,19 +262,19 @@ one is almost English: `log` the `sum` of the `range` of numbers from
263262
1 to 10. (We will see in link:04_data.html#data[later chapters] how to
264263
build things like `sum` and `range`.)
265264

266-
(((programming language,power of)))(((composition)))A good programming
267-
language helps the programmer by allowing them to talk about the
268-
actions that the computer has to perform on a higher level. It helps
269-
omit uninteresting details, provides convenient building blocks (such
270-
as `while` and `console.log`), allows you to define your own building
271-
blocks (such as `sum` and `range`), and makes it easy to compose these
272-
blocks.
265+
(((programming language,power of)))(((composability)))A good
266+
programming language helps the programmer by allowing them to talk
267+
about the actions that the computer has to perform on a higher level.
268+
It helps omit uninteresting details, provides convenient building
269+
blocks (such as `while` and `console.log`), allows you to define your
270+
own building blocks (such as `sum` and `range`), and makes it easy to
271+
compose these blocks.
273272

274273
== What is JavaScript? ==
275274

276275
indexsee:[WWW,World Wide Web] indexsee:[Web,World Wide Web]
277276

278-
(((history)))(((Netscape Navigator)))(((browser)))(((web
277+
(((history)))(((Netscape)))(((browser)))(((web
279278
application)))(((JavaScript)))(((JavaScript,history of)))(((World Wide
280279
Web))) JavaScript was introduced in 1995, as a way to add programs to
281280
Web pages in the Netscape Navigator browser. The language has since
@@ -357,10 +356,10 @@ at first, but I promise that you will quickly get the hang of it. The
357356
same goes for the ((exercises)). Don't assume you understand them
358357
until you've actually written a working solution.
359358

360-
I recommend to try out your solutions to exercises in an actual
361-
JavaScript ((interpreter)), to get immediate feedback on whether what
362-
you are doing is working or not, and, hopefully, to be tempted to
363-
((experiment)) and go beyond the exercises.
359+
(((interpretation)))I recommend to try out your solutions to exercises
360+
in an actual JavaScript interpreter, to get immediate feedback on
361+
whether what you are doing is working or not, and, hopefully, to be
362+
tempted to ((experiment)) and go beyond the exercises.
364363

365364
ifdef::html_target[]
366365

@@ -371,9 +370,9 @@ endif::html_target[]
371370

372371
ifdef::tex_target[]
373372

374-
(((download)))(((sandbox)))(((code sandbox)))(((running code)))Most of
375-
the example code in this book can be found on the book's ((website)),
376-
at http://eloquentjavascript.net/code[_eloquentjavascript.net/code_],
373+
(((download)))(((sandbox)))(((running code)))Most of the example code
374+
in this book can be found on the book's ((website)), at
375+
http://eloquentjavascript.net/code[_eloquentjavascript.net/code_],
377376
which also provides an easy way to run the programs and experiment
378377
with writing your own code.
379378

01_values.txt

Lines changed: 35 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,19 @@
55

66
= Values, Types, and Operators =
77

8+
[chapterquote="true"]
89
[quote, Master Yuan-Ma, The Book of Programming]
910
____
10-
(((Yuan-Ma)))(((Book of Programming, The)))Below the surface of the
11+
Below the surface of the
1112
machine, the program moves. Without effort, it expands and contracts.
1213
In great harmony, electrons scatter and regroup. The forms on the
1314
monitor are but ripples on the water. The essence stays invisibly
1415
below.
1516
____
1617

17-
(((binary data)))(((data)))(((bit)))(((memory)))Inside the computer's
18-
world, there is only data. You can read data, modify data, create new
18+
(((Yuan-Ma)))(((Book of Programming)))(((binary
19+
data)))(((data)))(((bit)))(((memory)))Inside the computer's world,
20+
there is only data. You can read data, modify data, create new
1921
data—but anything that isn't data simply does not exist. All this data
2022
is stored as long sequences of bits and is thus fundamentally alike.
2123

@@ -42,7 +44,7 @@ So that's the binary number 00001101, or 8 + 4 + 1, which equals 13.
4244

4345
== Values ==
4446

45-
(((memory)))(((volatile data storage)))(((hard disk)))Imagine a sea of
47+
(((memory)))(((volatile data storage)))(((hard drive)))Imagine a sea of
4648
bits. An ocean of them. A typical modern computer has more than 30
4749
billion bits in its volatile data storage. Nonvolatile storage (the
4850
hard disk or equivalent) tends to have yet a few orders of magnitude
@@ -105,7 +107,7 @@ computers have plenty of memory, so you are free to use 64-bit chunks,
105107
which means you need to worry about overflow only when dealing with
106108
truly astronomical numbers.
107109

108-
(((floating-point number)))(((fractional numbers)))(((sign bit)))Not
110+
(((sign)))(((floating-point number)))(((fractional number)))(((sign bit)))Not
109111
all whole numbers below 18 quintillion fit in a JavaScript number,
110112
though. Those bits also store negative numbers, so one bit indicates
111113
the sign of the number. A bigger issue is that nonwhole numbers must
@@ -158,11 +160,11 @@ number from them. Here is what they look like in JavaScript:
158160
100 + 4 * 11
159161
----
160162

161-
(((asterisk)))(((plus character)))(((pass:[*] operator)))(((+
162-
operator)))The `+` and `*` symbols are called _operators_. The first
163-
stands for addition, and the second stands for multiplication. Putting
164-
an operator between two values will (((application,of
165-
operators)))apply it to those values and produce a new value.
163+
(((operator,application)))(((asterisk)))(((plus
164+
character)))(((pass:[*] operator)))(((+ operator)))The `+` and `*`
165+
symbols are called _operators_. The first stands for addition, and the
166+
second stands for multiplication. Putting an operator between two
167+
values will apply it to those values and produce a new value.
166168

167169
(((grouping)))(((parentheses)))(((precedence)))Does the example mean
168170
“add 4 and 100, and multiply the result by 11”, or is the
@@ -220,8 +222,7 @@ numeric operations that don't yield a precise, meaningful result.
220222

221223
== Strings ==
222224

223-
(((syntax)))(((textual
224-
data)))(((character)))(((string,notation)))(((single-quote
225+
(((syntax)))(((text)))(((character)))(((string,notation)))(((single-quote
225226
character)))(((double-quote character)))(((quotation mark)))The next
226227
basic data type is the _((string))_. Strings are used to represent
227228
text. They are written by enclosing their content in quotes.
@@ -242,9 +243,9 @@ quotes between quotes might be hard. _Newlines_ (the characters you
242243
get when you press Enter) also can't be put between quotes. The string
243244
has to stay on a single line.
244245

245-
(((escaping,in strings)))(((backslash)))To be able to have such
246-
characters in a string, the following notation is used: whenever a
247-
backslash (“\”) is found inside quoted text, it indicates that the
246+
(((escaping,in strings)))(((backslash character)))To be able to have
247+
such characters in a string, the following notation is used: whenever
248+
a backslash (“\”) is found inside quoted text, it indicates that the
248249
character after it has a special meaning. This is called _escaping_
249250
the character. A quote that is preceded by a backslash will not end
250251
the string but be part of it. When an “n” character occurs after a
@@ -442,11 +443,11 @@ necessary:
442443
1 + 1 == 2 && 10 * 10 > 50
443444
----
444445

445-
(((ternary operator)))(((?: operator)))(((conditional
446-
operator)))(((colon character)))(((question mark)))The last logical
447-
operator I will discuss is not unary, not binary, but _ternary_,
448-
operating on three values. It is written with a question mark and a
449-
colon, like this:
446+
(((conditional execution)))(((ternary operator)))(((?:
447+
operator)))(((conditional operator)))(((colon character)))(((question
448+
mark)))The last logical operator I will discuss is not unary, not
449+
binary, but _ternary_, operating on three values. It is written with a
450+
question mark and a colon, like this:
450451

451452
[source,javascript]
452453
----
@@ -480,7 +481,7 @@ recommend treating them as interchangeable (more on that in a moment).
480481

481482
== Automatic type conversion ==
482483

483-
(((NaN)))(((type conversion)))In the introduction, I mentioned that
484+
(((NaN)))(((type coercion)))In the introduction, I mentioned that
484485
JavaScript goes out of its way to accept almost any program you give
485486
it, even programs that do odd things. This is nicely demonstrated by
486487
the following expressions:
@@ -509,11 +510,12 @@ to number). Yet in the third expression, `+` tries string
509510
concatenation before numeric addition, so the `1` is converted to
510511
`"1"` (from number to string).
511512

512-
When something that doesn't map to a number in an obvious way (such as
513-
`"five"` or `undefined`) is converted to a number, the value `NaN` is
514-
produced. Further arithmetic operations on `NaN` keep producing
515-
`NaN`, so if you find yourself getting one of those in an unexpected
516-
place, look for accidental type conversions.
513+
(((type coercion)))(((number,conversion to)))When something that
514+
doesn't map to a number in an obvious way (such as `"five"` or
515+
`undefined`) is converted to a number, the value `NaN` is produced.
516+
Further arithmetic operations on `NaN` keep producing `NaN`, so if you
517+
find yourself getting one of those in an unexpected place, look for
518+
accidental type conversions.
517519

518520
(((null)))(((undefined)))(((comparison,of undefined values)))(((==
519521
operator)))When comparing values of the same type using `==`, the
@@ -537,7 +539,7 @@ That last piece of behavior is often useful. When you want to test
537539
whether a value has a real value instead of `null` or `undefined`, you
538540
can simply compare it to `null` with the `==` (or `!=`) operator.
539541

540-
(((Boolean,conversion to)))(((=== operator)))(((!==
542+
(((type coercion)))(((Boolean,conversion to)))(((=== operator)))(((!==
541543
operator)))(((comparison)))But what if you want to test whether
542544
something refers to the precise value `false`? The rules for
543545
converting strings and numbers to Boolean values state that `0`,
@@ -556,11 +558,12 @@ using the shorter operators.
556558

557559
=== Short-circuiting of logical operators ===
558560

559-
(((operator)))The logical operators `&&` and `||` handle values of
560-
different types in a peculiar way. They will convert the value on
561-
their left side to Boolean type in order to decide what to do, but
562-
depending on the operator and the result of that conversion, they
563-
return either the _original_ left-hand value or the right-hand value.
561+
(((type coercion)))(((Boolean,conversion to)))(((operator)))The
562+
logical operators `&&` and `||` handle values of different types in a
563+
peculiar way. They will convert the value on their left side to
564+
Boolean type in order to decide what to do, but depending on the
565+
operator and the result of that conversion, they return either the
566+
_original_ left-hand value or the right-hand value.
564567

565568
(((|| operator)))The `||` operator, for example, will return the value
566569
to its left when that can be converted to true and will return the

02_program_structure.txt

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,17 @@
77
[chapterquote="true"]
88
[quote, _why, Why's (Poignant) Guide to Ruby]
99
____
10-
(((why)))(((Poignant Guide)))And my heart glows bright red under my
10+
And my heart glows bright red under my
1111
filmy, translucent skin and they have to administer 10cc of JavaScript
1212
to get me to come back. (I respond well to toxins in the blood.) Man,
1313
that stuff will kick the peaches right out your gills!
1414
____
1515

16-
In this chapter, we will start to do things that can actually be
17-
called _programming_. We will expand our command of the JavaScript
18-
language beyond the nouns and sentence fragments we've seen so far,
19-
to the point where we can actually express some meaningful prose.
16+
(((why)))(((Poignant Guide)))In this chapter, we will start to do
17+
things that can actually be called _programming_. We will expand our
18+
command of the JavaScript language beyond the nouns and sentence
19+
fragments we've seen so far, to the point where we can actually
20+
express some meaningful prose.
2021

2122
== Expressions and statements ==
2223

@@ -171,10 +172,10 @@ console.log(one + two);
171172
== Keywords and reserved words ==
172173

173174
(((syntax)))(((implements (reserved word))))(((interface (reserved
174-
word))))(((let reserved word)))(((package (reserved word))))(((private
175-
reserved word)))(((protected (reserved word))))(((public reserved
176-
words)))(((static (reserved word))))(((void operator)))(((yield
177-
(reserved word))))(((reserved words)))(((variable,naming)))Words with
175+
word))))(((let keyword)))(((package (reserved word))))(((private
176+
(reserved word))))(((protected (reserved word))))(((public (reserved
177+
word))))(((static (reserved word))))(((void operator)))(((yield
178+
(reserved word))))(((reserved word)))(((variable,naming)))Words with
178179
a special meaning, such as `var`, are _((keyword))s_, and they may not
179180
be used as variable names. There are also a number of words that are
180181
“reserved for use” in ((future)) versions of JavaScript. These are also
@@ -211,13 +212,13 @@ indexsee:[application (of functions),function application]
211212
indexsee:[invoking (of functions),function application]
212213
indexsee:[calling (of functions),function application]
213214

214-
(((output)))(((function)))(((function,application)))(((Function
215-
type)))(((alert function)))(((message box)))A lot of the values
216-
provided in the default environment have the type _((function))_. A
217-
function is a piece of program wrapped in a value. Such values can be
218-
_applied_ in order to run the wrapped program. For example, in a
219-
((browser)) environment, the variable `alert` holds a function that
220-
shows a little ((dialog box)) with a message. It is used like this:
215+
(((output)))(((function)))(((function,application)))(((alert
216+
function)))(((message box)))A lot of the values provided in the
217+
default environment have the type _((function))_. A function is a
218+
piece of program wrapped in a value. Such values can be _applied_ in
219+
order to run the wrapped program. For example, in a ((browser))
220+
environment, the variable `alert` holds a function that shows a little
221+
((dialog box)) with a message. It is used like this:
221222

222223
[source,javascript]
223224
----
@@ -226,7 +227,7 @@ alert("Good morning!");
226227

227228
image::img/alert.png[alt="An alert dialog",width="8cm"]
228229

229-
(((parameters)))(((function,application)))Executing a function is
230+
(((parameter)))(((function,application)))Executing a function is
230231
called _invoking_, _calling_, or _applying_ it. You can call a
231232
function by putting ((parentheses)) after an expression that produces a
232233
function value. Usually you'll directly use the name of a variable
@@ -267,8 +268,6 @@ console.log("the value of x is", x);
267268
// → the value of x is 30
268269
----
269270

270-
indexsee:[field,property]
271-
272271
(((object)))Though ((variable)) names cannot contain ((period
273272
character))s, `console.log` clearly has one. This is because
274273
`console.log` isn't a simple variable. It is actually an expression
@@ -357,12 +356,13 @@ alert("Your number is the square root of " +
357356
theNumber * theNumber);
358357
----
359358

360-
(((type conversion)))(((Number function)))(((String
361-
function)))(((Boolean function)))(((Boolean type,conversion to)))The
362-
function `Number` converts a value to a number. We need that
363-
conversion because the result of `prompt` is a string value, and we
364-
want a number. There are similar functions called `String` and
365-
`Boolean` that convert values to those types.
359+
(((number,conversion to)))(((type coercion)))(((Number
360+
function)))(((String function)))(((Boolean
361+
function)))(((Boolean,conversion to)))The function `Number` converts a
362+
value to a number. We need that conversion because the result of
363+
`prompt` is a string value, and we want a number. There are similar
364+
functions called `String` and `Boolean` that convert values to those
365+
types.
366366

367367
Here is the rather trivial schematic representation of straight
368368
control flow:
@@ -562,7 +562,7 @@ except `""` convert to `true`.
562562

563563
== Indenting Code ==
564564

565-
(((block)))(((code,structure of)))(((whitespace)))(((programming
565+
(((block)))(((code structure)))(((whitespace)))(((programming
566566
style)))You've probably noticed the spaces I put in front of some
567567
statements. In JavaScript, these are not required—the computer will
568568
accept the program just fine without them. In fact, even the ((line))
@@ -646,7 +646,7 @@ console.log(current);
646646
// → 21
647647
----
648648

649-
(((remainder operation)))(((% operator)))The trick with the remainder
649+
(((remainder operator)))(((% operator)))The trick with the remainder
650650
(`%`) operator is an easy way to test whether a number is divisible by
651651
another number. If it is, the remainder of their division is zero.
652652

@@ -713,7 +713,7 @@ for (var number = 0; number <= 12; number += 2)
713713

714714
== Dispatching on a value with switch ==
715715

716-
(((syntax)))(((conditional execution)))(((dispatch)))(((if
716+
(((syntax)))(((conditional execution)))(((dispatching)))(((if
717717
keyword,chaining)))It is common for code to look like this:
718718

719719
// test: no
@@ -1004,7 +1004,7 @@ order in which we build up the string (line by line, left to right,
10041004
top to bottom). So the outer loop handles the lines and the inner loop
10051005
handles the characters on a line.
10061006

1007-
(((counter variable)))(((remainder operation)))(((% operator)))You'll
1007+
(((counter variable)))(((remainder operator)))(((% operator)))You'll
10081008
need two variables to track your progress. To know whether to put a
10091009
space or a hash sign at a given position, you could test whether the
10101010
sum of the two counters is even (`% 2`).

0 commit comments

Comments
 (0)