Commit adb38bb1 authored by MohammadAli Keshavarz's avatar MohammadAli Keshavarz

Truthy and Falsy values and equality operators

parent dd9c9926
......@@ -153,7 +153,7 @@ if (age < 13) {
/*****************************
* The Ternary Operator and Switch Statements
*/
/*
var firstName = 'John';
var age = 14;
// Ternary operator
......@@ -197,4 +197,21 @@ switch (true) {
}
/*****************************
* Truthy and Falsy values and equality operators
*/
// falsy values: undefined, null, 0, '', NaN
// truthy values: NOT falsy values
var height;
height = 23;
if (height || height === 0) {
console.log('Variable is defined');
} else {
console.log('Variable has NOT been defined');
}
// Equality operators
if (height === '23') {
console.log('The == operator does type coercion!');
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment