@@ -145,7 +145,7 @@ a new number from them. Here is what they look like in JavaScript:
145145100 + 4 * 11
146146----
147147
148- (((\* operator)))(((+ operator)))The “+” and “*” symbols are called
148+ (((\* operator)))(((+ operator)))The `+` and `*` symbols are called
149149_operators_. The first stands for addition, and the second stands for
150150multiplication. Putting an operator between two values will
151151(((application,of operators)))apply it to those values and produce a
@@ -163,21 +163,21 @@ parentheses.
163163----
164164
165165(((division)))(((subtraction)))(((- operator)))(((/ operator)))For
166- subtraction, there is the “-” operator, and division can be done with
167- the “/” operator.
166+ subtraction, there is the `-` operator, and division can be done with
167+ the `/` operator.
168168
169169When operators appear together without parentheses, the order in which
170170they are applied is determined by the _((precedence))_ of the
171171operators. The example shows that multiplication comes before
172- addition. “/” has the same precedence as “*” . Likewise for “+” and
173- “-” . When multiple operators with the same precedence appear next to
172+ addition. `/` has the same precedence as `*` . Likewise for `+` and
173+ `-` . When multiple operators with the same precedence appear next to
174174each other (as in `1 - 2 + 1`), they are applied left to right.
175175
176176These rules of precedence are not something you should worry about.
177177When in doubt, just add parentheses.
178178
179179(((remainder operation)))(((% operator)))There is one more arithmetic
180- operator, which you might not recognize. The “%” symbol is used to
180+ operator, which you might not recognize. The `%` symbol is used to
181181represent the _remainder_ operation. `X % Y` is the remainder of
182182dividing `X` by `Y`. For example, `314 % 100` produces `14`, and `144
183183% 12` gives `0`. Remainder's precedence is the same as that of
@@ -257,7 +257,7 @@ character is written like "\n"`” can be written:
257257----
258258
259259(((+ operator)))(((concatenation)))Strings cannot be divided,
260- multiplied, or subtracted, but the “+” operator _can_ be used on them.
260+ multiplied, or subtracted, but the `+` operator _can_ be used on them.
261261It does not add, but it __concatenates__—it glues two strings together.
262262The following line will produce the string `"concatenate"`:
263263
@@ -322,7 +322,7 @@ console.log(3 < 2)
322322----
323323
324324(((> operator)))(((< operator)))(((greater than)))(((less
325- than)))(((comparing)))The “>” and “<” signs are the traditional symbols
325+ than)))(((comparing)))The `>` and `<` signs are the traditional symbols
326326for “is greater than” and “is less than”, respectively. They are binary operators.
327327Applying them results in a boolean value that indicates
328328whether they hold true in this case.
@@ -348,9 +348,9 @@ JavaScript goes over them from left to right, comparing the numeric
348348codes of the characters one by one.
349349
350350(((>= operator)))(((<= operator)))(((== operator)))(((!=
351- operator)))Other similar operators are “>=” (greater than or equal
352- to), “ \<=” (less than or equal to), “==” (equal to), and
353- “!=” (not equal to).
351+ operator)))Other similar operators are `>=` (greater than or equal
352+ to), ` \<=` (less than or equal to), `==` (equal to), and
353+ `!=` (not equal to).
354354
355355[source,javascript]
356356----
@@ -377,7 +377,7 @@ applied to Boolean values themselves. JavaScript supports three
377377logical operators: _and_, _or_, and _not_. These can be used to
378378“reason” about Booleans.
379379
380- (((&& operator)))The “&&” operator represents logical _and_. It is a
380+ (((&& operator)))The `&&` operator represents logical _and_. It is a
381381binary operator, and its result is true only if both the values
382382given to it are true.
383383
@@ -389,7 +389,7 @@ console.log(true && true)
389389// → true
390390----
391391
392- (((|| operator)))The “||” operator denotes logical _or_. It produces
392+ (((|| operator)))The `||` operator denotes logical _or_. It produces
393393true if either of the values given to it is true.
394394
395395[source,javascript]
@@ -401,14 +401,14 @@ console.log(false || false)
401401----
402402
403403(((negation)))(((! operator)))_Not_ is written as an exclamation mark
404- (“!” ). It is a unary operator that flips the value given to it—`!true`
404+ (`!` ). It is a unary operator that flips the value given to it—`!true`
405405produces `false` and `!false` gives `true`.
406406
407407(((precedence)))When mixing these Boolean operators with arithmetic
408408and other operators, it is not always obvious when parentheses are
409409needed. In practice, you can usually get by with knowing that of the
410- operators we have seen so far, “||” has the lowest precedence, then
411- comes “&&” , then the comparison operators (“>”, “==” , and so on), and
410+ operators we have seen so far, `||` has the lowest precedence, then
411+ comes `&&` , then the comparison operators (`>`, `==` , and so on), and
412412then the rest. This order has been chosen such that, in typical
413413expressions like the following one, as few parentheses as possible are
414414necessary:
@@ -489,7 +489,7 @@ produced. Further arithmetic operations on `NaN` keep producing
489489`NaN`, so if you find yourself getting one of those in an unexpected
490490place, look for accidental type conversions.
491491
492- (((== operator)))When comparing values of the same type using “==” ,
492+ (((== operator)))When comparing values of the same type using `==` ,
493493the outcome is easy to predict: you should get true when both
494494values are the same. But when the types differ, JavaScript uses a
495495complicated and confusing set of rules to determine what to do. I will
@@ -508,8 +508,8 @@ console.log(null == 0);
508508
509509That last piece of behavior is often useful. When you want to
510510test whether a value has a real value instead of `null`
511- or `undefined`, you can simply compare it to `null` with the “==” (or
512- “!=” ) operator.
511+ or `undefined`, you can simply compare it to `null` with the `==` (or
512+ `!=` ) operator.
513513
514514(((=== operator)))(((!== operator)))But what if you want to test
515515whether something refers to the precise value `false`? The rules for
@@ -518,7 +518,7 @@ converting strings and numbers to Boolean values state that `0`,
518518values count as `true`. Because of this, expressions like `0 == false`
519519and `"" == false` are also true. For cases like this, where you do
520520_not_ want any automatic type conversions to happen, there are two
521- extra operators: “ ===” and “ !==” . The first tests whether a value is
521+ extra operators: ` ===` and ` !==` . The first tests whether a value is
522522precisely equal to the other, and the second tests whether it is not
523523precisely equal. So `"" === false` is false as expected.
524524
@@ -530,13 +530,13 @@ using the shorter operators.
530530=== Short-circuiting of logical operators ===
531531
532532(((|| operator)))(((&& operator)))(((?: operator)))(((operator)))The
533- logical operators “&&” and “||” handle values of different types in a
533+ logical operators `&&` and `||` handle values of different types in a
534534peculiar way. They _will_ convert the value on their left side to
535535boolean type in order to decide what to do, but depending on the
536536operator and the result of that conversion, they return either the
537537_original_ left-hand value or the right-hand value.
538538
539- The “||” operator, for example, will return the value to its left when that can be
539+ The `||` operator, for example, will return the value to its left when that can be
540540converted to true and will return the value on its right otherwise. This conversion works as
541541you'd expect for boolean values and should do something analogous for
542542values of other types.
@@ -554,7 +554,7 @@ to fall back on a default value. If you give it an expression that might produce
554554an empty value on the left, the value on the right will be used as a replacement
555555in that case.
556556
557- The “&&” operator works similarly, but the other way around. When the
557+ The `&&` operator works similarly, but the other way around. When the
558558value to its left is something that converts to false, it returns that
559559value, and otherwise it returns the value on its right.
560560
@@ -576,10 +576,10 @@ strings, Booleans, and undefined values.
576576
577577Such values are created by typing in their name (`true`, `null`) or
578578value (`13`, `"abc"`). You can combine and transform values with operators. We saw binary
579- operators for arithmetic (“+”, “-”, “*”, “/” ,
580- and “%” ), string concatenation (“+” ), comparison (“==”, “!=” ,
581- “ ===”, “ !==”, “<”, “>”, “ \<=”, “>=” ), and logic (“&&”, “||” ), as well
582- as several unary operators (“-” to negate a number, “!” to negate
579+ operators for arithmetic (`+`, `-`, `*`, `/` ,
580+ and `%` ), string concatenation (`+` ), comparison (`==`, `!=` ,
581+ ` ===`, ` !==`, `<`, `>`, ` \<=`, `>=` ), and logic (`&&`, `||` ), as well
582+ as several unary operators (`-` to negate a number, `!` to negate
583583logically, and `typeof` to find a value's type).
584584
585585This gives you enough information to use JavaScript as a pocket
0 commit comments