Booleans
true
or false
There are other data types that can yield true or false values on comparison
True: true
, 1
, 'Hello'
False: false
, 0
, ''
Operators
// Logical Operators &&, ||, !
// Comparison Operators >, >=, <, <=, ==, ===, !=, !==
Double Equals vs. Triple Equals
('3' == 3 ) // True, because JS interpreter converts the string into a number.
('3' === 3 ) // False, type comparison is included.
(' ' == 0 ) // True.
(' ' === 0 ) // False.
( 'Ruby' < 'Python' ) // False. P comes before R in the alphabet.
If – Else If – Else
if ( condition ) {
//code block 1
} else if ( condition ){
//code block 2
} else {
//code block 3
}