GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Merge pull request #46 from hasselg/equality_fixes · eliooses/javascript@d8a8be6

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • basics
    • equality.md
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎basics/equality.md‎

Copy file name to clipboardExpand all lines: basics/equality.md
+4-5Lines changed: 4 additions & 5 deletions
  • Display the source diff
  • Display the rich diff
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 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.