summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorAdam Bard <github@adambard.com>2014-10-27 19:32:39 +0200
committerAdam Bard <github@adambard.com>2014-10-27 19:32:39 +0200
commit2a6e60d83be7e778fb684b1c417f9175f5a768a3 (patch)
treee05b860c3bb5a291ff0f683767447496bb7bb65c
parent92db780adc88f7e9d7890d37fe30bb1b2ee8018f (diff)
parentfb28f2c10258eb92dc40db648a304f3e5b78bd2f (diff)
Merge pull request #828 from ml242/master
Use === in js tutorial except once demonstrating ==
-rw-r--r--javascript.html.markdown16
1 files changed, 9 insertions, 7 deletions
diff --git a/javascript.html.markdown b/javascript.html.markdown
index 7c869b28..cc210c4a 100644
--- a/javascript.html.markdown
+++ b/javascript.html.markdown
@@ -77,13 +77,13 @@ false;
!true; // = false
!false; // = true
-// Equality is ==
-1 == 1; // = true
-2 == 1; // = false
+// Equality is ===
+1 === 1; // = true
+2 === 1; // = false
-// Inequality is !=
-1 != 1; // = false
-2 != 1; // = true
+// Inequality is !==
+1 !== 1; // = false
+2 !== 1; // = true
// More comparisons
1 < 10; // = true
@@ -97,11 +97,13 @@ false;
// and are compared with < and >
"a" < "b"; // = true
-// Type coercion is performed for comparisons...
+// Type coercion is performed for comparisons with double equals...
"5" == 5; // = true
+null == undefined; // = true
// ...unless you use ===
"5" === 5; // = false
+null === undefined; // = false
// You can access characters in a string with charAt
"This is a string".charAt(0); // = 'T'