Skip to content

Commit 465800c

Browse files
committed
Typo/style fixes.
Fixed typo in first sentence describing how == works. Set syntax highlighting to Javascript mode. Added missing highlight to an occurrence of 'false'. Removed effectively superflous '.' around the big code block.
1 parent cd06f39 commit 465800c

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

basics/equality.md

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,16 @@
22

33
Programmers frequently need to determine the equality of variables in relation to other variables. This is done using an equality operator.
44

5-
The most basic equality operator is the `==` operator. This operator does everything it can to make determine if two variables are equal, even if they are not of the same type.
5+
The most basic equality operator is the `==` operator. This operator does everything it can to determine if two variables are equal, even if they are not of the same type.
66

7-
For example, assume
8-
```
7+
For example, assume:
8+
```javascript
99
var foo = 42;
1010
var bar = 42;
1111
var baz = "42";
1212
var qux = "life";
1313
```
14-
.
1514

16-
`foo == bar` will evaluate to `true` and `baz == qux` will evaluate to false, as one would expect. However, `foo == baz` will *also* evaluate to `true` despite `foo` and `baz` being different types. Behind the scenes the `==` equality operator attempts to force its operands to the same type before determining their equality. This is in contrast to the `===` equality operator.
15+
`foo == bar` will evaluate to `true` and `baz == qux` will evaluate to `false`, as one would expect. However, `foo == baz` will *also* evaluate to `true` despite `foo` and `baz` being different types. Behind the scenes the `==` equality operator attempts to force its operands to the same type before determining their equality. This is in contrast to the `===` equality operator.
1716

1817
The `===` equality operator determines that two variables are equal if they are of the same type *and* have the same value. With the same assumptions as before, this means that `foo === bar` will still evaluate to `true`, but `foo === baz` will now evaluate to `false`. `baz === qux` will still evaluate to `false`.

0 commit comments

Comments
 (0)