| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -8,7 +8,7 @@ if (country === "France") { | |||
| 8 | 8 | } | |
| 9 | 9 | ``` | |
| 10 | 10 | ||
| 11 | - The conditional part is the country followed by the three equal signs (`===`). Three equal signs mean that the condition tests if the variable country has the value you test against but also the correct variable (data)type. You can test conditions with double equal signs, too, but that would mean that `if(x == 5)` would be true for x being 5 and x being “5”. Depending on what your program is doing, this could make quite a difference. | ||
| 11 | + The conditional part is the variable `country` followed by the three equal signs (`===`). Three equal signs tests if the variable `country` has both the correct value (`France`) and also the correct type (`String`). You can test conditions with double equal signs, too, however a conditional such as `if (x == 5)` would then return true for both `var x = 5;` and `var x = "5";`. Depending on what your program is doing, this could make quite a difference. It is highly recommended as a best practice that you always compare equality with three equal signs (`===` and `!==`) instead of two (`==` and `!=`). | ||
| 12 | 12 | ||
| 13 | 13 | Other conditional test: | |
| 14 | 14 | ||
@@ -21,7 +21,7 @@ Other conditional test: | |||
| 21 | 21 | ||
| 22 | 22 | --- | |
| 23 | 23 | ||
| 24 | - Add a condition to change the value of `a` to 10 if `x` is bigger than 5. | ||
| 24 | + Add a condition to change the value of `a` to the number 10 if `x` is bigger than 5. | ||
| 25 | 25 | ||
| 26 | 26 | ```js | |
| 27 | 27 | var x = 6; | |
@@ -40,7 +40,7 @@ if (x > 5) { | |||
| 40 | 40 | ``` | |
| 41 | 41 | ||
| 42 | 42 | ```js | |
| 43 | - assert(a == 10); | ||
| 43 | + assert(a === 10); | ||
| 44 | 44 | ``` | |
| 45 | 45 | ||
| 46 | - --- | ||
| 46 | + --- | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments