mirror of
https://github.com/adambard/learnxinyminutes-docs.git
synced 2024-12-24 01:51:38 +00:00
Merge pull request #828 from ml242/master
Use === in js tutorial except once demonstrating ==
This commit is contained in:
commit
2a6e60d83b
@ -77,13 +77,13 @@ false;
|
|||||||
!true; // = false
|
!true; // = false
|
||||||
!false; // = true
|
!false; // = true
|
||||||
|
|
||||||
// Equality is ==
|
// Equality is ===
|
||||||
1 == 1; // = true
|
1 === 1; // = true
|
||||||
2 == 1; // = false
|
2 === 1; // = false
|
||||||
|
|
||||||
// Inequality is !=
|
// Inequality is !==
|
||||||
1 != 1; // = false
|
1 !== 1; // = false
|
||||||
2 != 1; // = true
|
2 !== 1; // = true
|
||||||
|
|
||||||
// More comparisons
|
// More comparisons
|
||||||
1 < 10; // = true
|
1 < 10; // = true
|
||||||
@ -97,11 +97,13 @@ false;
|
|||||||
// and are compared with < and >
|
// and are compared with < and >
|
||||||
"a" < "b"; // = true
|
"a" < "b"; // = true
|
||||||
|
|
||||||
// Type coercion is performed for comparisons...
|
// Type coercion is performed for comparisons with double equals...
|
||||||
"5" == 5; // = true
|
"5" == 5; // = true
|
||||||
|
null == undefined; // = true
|
||||||
|
|
||||||
// ...unless you use ===
|
// ...unless you use ===
|
||||||
"5" === 5; // = false
|
"5" === 5; // = false
|
||||||
|
null === undefined; // = false
|
||||||
|
|
||||||
// You can access characters in a string with charAt
|
// You can access characters in a string with charAt
|
||||||
"This is a string".charAt(0); // = 'T'
|
"This is a string".charAt(0); // = 'T'
|
||||||
|
Loading…
Reference in New Issue
Block a user