Skip to content

Commit 5537f11

Browse files
Markus Amalthea Magnusonajpiano
Markus Amalthea Magnuson
authored andcommitted
Various small fixes on the JavaScript 101 Operators page. Fixes jquery#349.
1 parent ee96e5e commit 5537f11

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

page/javascript-101/operators.md

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ source: http://jqfundamentals.com/legacy
55
attribution:
66
- jQuery Fundamentals
77
---
8+
89
Basic operators allow you to manipulate values.
910

1011
```
@@ -47,26 +48,27 @@ console.log( foo + bar ); // 12
4748
```
4849

4950
```
50-
// Coercing a string to act as a number:
51+
// Coercing a string to act as a number.
5152
var foo = 1;
5253
var bar = "2";
5354
5455
console.log( foo + Number(bar) ); // 3
5556
```
5657

57-
The Number constructor, when called as a function (as in the above example), will have the effect of casting its argument into a number. The unary plus operator also does the same thing:
58+
The `Number` constructor, when called as a function (as in the above example), will have the effect of casting its argument into a number. The unary plus operator also does the same thing:
5859

5960
```
60-
// Forcing a string to act as a number (using the unary plus operator):
61+
// Forcing a string to act as a number (using the unary plus operator).
6162
console.log( foo + +bar ); // 3
6263
```
6364

6465
## Logical Operators
6566

66-
Logical operators allow evaluation of a series of operands using AND ( `&&` ) and OR ( `||` ) operations.
67+
Logical operators allow evaluation of a series of operands using AND (`&&`) and OR (`||`) operations.
6768

6869
```
6970
// Logical AND and OR operators
71+
7072
var foo = 1;
7173
var bar = 0;
7274
var baz = 2;
@@ -92,10 +94,10 @@ In the above example, the `||` operator returns the value of the first truthy op
9294
You'll sometimes see developers use these logical operators for flow control instead of using `if` statements. For example:
9395

9496
```
95-
// do something with foo if foo is truthy
97+
// Do something with foo if foo is truthy.
9698
foo && doSomething( foo );
9799
98-
// set bar to baz if baz is truthy;
100+
// Set bar to baz if baz is truthy;
99101
// otherwise, set it to the return value of createBar()
100102
var bar = baz || createBar();
101103
```
@@ -108,6 +110,7 @@ Comparison operators allow you to test whether values are equivalent or whether
108110

109111
```
110112
// Comparison operators
113+
111114
var foo = 1;
112115
var bar = 0;
113116
var baz = "1";
@@ -125,4 +128,5 @@ foo > bim; // false
125128
bim > baz; // true
126129
foo <= baz; // true
127130
```
131+
128132
For more information about comparison operators, visit the [Mozilla Developer Network](https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Operators/Comparison_Operators "MDN - Comparison Operators").

0 commit comments

Comments
 (0)