Skip to content

Commit 371c6a3

Browse files
committed
Add index entries for Chapter 2
1 parent 1b27c3c commit 371c6a3

File tree

4 files changed

+438
-402
lines changed

4 files changed

+438
-402
lines changed

00_intro.txt

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,10 @@ interfaces, such as instructing the computer to perform arbitrary
2525
tasks, we've had more luck with an approach that makes use of our
2626
talent for language: teaching the machine a language.
2727

28-
Human languages allow words and sub-sentences to be combined in many,
29-
many ways, allowing us to say many, many different things. Computer
30-
languages, though typically less grammatically flexible, follow a
31-
similar principle.
28+
(((human language)))Human languages allow words and subsentences to be
29+
combined in many, many ways, allowing us to say many, many different
30+
things. Computer languages, though typically less grammatically
31+
flexible, follow a similar principle.
3232

3333
(((JavaScript,availability of)))(((browser)))Casual computing has
3434
become become much more widespread in the past twenty years, and
@@ -385,11 +385,11 @@ browser.
385385

386386
== Typographic conventions ==
387387

388-
In this book, text written in a `monospaced` font should be understood
389-
to represent elements of programs—sometimes they are self-sufficient
390-
fragments, and sometimes they just refer to part of a nearby program.
391-
Programs (of which you have already seen a few), are written as
392-
follows:
388+
(((factorial function)))In this book, text written in a `monospaced`
389+
font should be understood to represent elements of programs—sometimes
390+
they are self-sufficient fragments, and sometimes they just refer to
391+
part of a nearby program. Programs (of which you have already seen a
392+
few), are written as follows:
393393

394394
[source,javascript]
395395
----
@@ -401,9 +401,9 @@ function fac(n) {
401401
}
402402
----
403403

404-
Sometimes, in order to show the output that a program produces, the
405-
expected output is written below it, with two slashes and an arrow in
406-
front:
404+
(((console.log)))Sometimes, in order to show the output that a program
405+
produces, the expected output is written below it, with two slashes
406+
and an arrow in front:
407407

408408
[source,javascript]
409409
----

01_values.txt

Lines changed: 27 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -232,11 +232,12 @@ their content in quotes.
232232
Both single and double quotes can be used to mark strings as long as
233233
the quotes at the start and the end of the string match.
234234

235-
(((newline)))Almost anything can be put between quotes, and JavaScript
236-
will make a string value out of it. But a few characters are more
237-
difficult. You can imagine how putting quotes between quotes might be
238-
hard. _Newlines_ (the characters you get when you press Enter) also
239-
can't be put between quotes. The string has to stay on a single line.
235+
(((newline character)))Almost anything can be put between quotes, and
236+
JavaScript will make a string value out of it. But a few characters
237+
are more difficult. You can imagine how putting quotes between quotes
238+
might be hard. _Newlines_ (the characters you get when you press
239+
Enter) also can't be put between quotes. The string has to stay on a
240+
single line.
240241

241242
(((escaping,in strings)))(((backslash)))To be able to have such
242243
characters in a string, the following notation is used: whenever a
@@ -245,7 +246,7 @@ character after it has a special meaning. This is called _escaping_
245246
the character. A quote that is preceded by a backslash will not end
246247
the string but be part of it. When an “n” character occurs after a
247248
backslash, it is interpreted as a newline. Similarly, a “t” after a
248-
backslash means a tab character. Take the following string:
249+
backslash means a ((tab character)). Take the following string:
249250

250251
[source,javascript]
251252
----
@@ -494,15 +495,15 @@ console.log(false == 0)
494495
// → true
495496
----
496497

497-
(((+ operator)))(((arithmetic)))(((* operator)))(((- operator)))When
498-
an operator is applied to the “wrong” type of value, JavaScript will
499-
quietly convert that value to the type it wants, using a set of rules
500-
that often aren't what you want or expect. This is called _type
501-
coercion_. So the `null` in the first expression becomes `0`, and the
502-
`"5"` in the second expression becomes `5` (from string to number).
503-
Yet in the third expression, `+` tries string concatenation before
504-
numeric addition, so the `1` is converted to `"1"` (from number to
505-
string).
498+
(((+ operator)))(((arithmetic)))(((pass:[*] operator)))(((-
499+
operator)))When an operator is applied to the “wrong” type of value,
500+
JavaScript will quietly convert that value to the type it wants, using
501+
a set of rules that often aren't what you want or expect. This is
502+
called _((type coercion))_. So the `null` in the first expression becomes
503+
`0`, and the `"5"` in the second expression becomes `5` (from string
504+
to number). Yet in the third expression, `+` tries string
505+
concatenation before numeric addition, so the `1` is converted to
506+
`"1"` (from number to string).
506507

507508
When something that doesn't map to a number in an obvious way (such as
508509
`"five"` or `undefined`) is converted to a number, the value `NaN` is
@@ -532,17 +533,17 @@ That last piece of behavior is often useful. When you want to test
532533
whether a value has a real value instead of `null` or `undefined`, you
533534
can simply compare it to `null` with the `==` (or `!=`) operator.
534535

535-
(((=== operator)))(((!== operator)))(((comparison)))But what if you
536-
want to test whether something refers to the precise value `false`?
537-
The rules for converting strings and numbers to Boolean values state
538-
that `0`, `NaN`, and the empty string (`""`) count as `false`, while
539-
all the other values count as `true`. Because of this, expressions
540-
like `0 == false` and `"" == false` are also true. For cases like
541-
this, where you do _not_ want any automatic type conversions to
542-
happen, there are two extra operators: `===` and `!==`. The first
543-
tests whether a value is precisely equal to the other, and the second
544-
tests whether it is not precisely equal. So `"" === false` is false as
545-
expected.
536+
(((Boolean type,conversion to)))(((=== operator)))(((!==
537+
operator)))(((comparison)))But what if you want to test whether
538+
something refers to the precise value `false`? The rules for
539+
converting strings and numbers to Boolean values state that `0`,
540+
`NaN`, and the empty string (`""`) count as `false`, while all the
541+
other values count as `true`. Because of this, expressions like `0 ==
542+
false` and `"" == false` are also true. For cases like this, where you
543+
do _not_ want any automatic type conversions to happen, there are two
544+
extra operators: `===` and `!==`. The first tests whether a value is
545+
precisely equal to the other, and the second tests whether it is not
546+
precisely equal. So `"" === false` is false as expected.
546547

547548
I recommend using the three-character comparison operators defensively to
548549
prevent unexpected type conversions from tripping you up. But when you're

0 commit comments

Comments
 (0)