What's a Falsy value??

A Falsy value is a value that is considered false when evaluated in an if else condition.

In addition, there are basically 5 types/classes of Falsy values , some of which include;

  1. Undefined
  2. Null
  3. 0 (zero)
  4. ' ' (empty string)
  5. NaN (not a number).

Before we sight examples and draw analogies, Let us take a look at Truthy values

There is no gainsaying that Truthy values are the opposite of Falsy values, meaning they are the values considered true in an if else condition. In short, they're not (!) Falsy values.

Code snippet to illustrate the above 'jargons'

var height;
if(height) {
    console.log('variable is defined')
}else {
   console.log('variable is not defined')
}
// console prints 'variable is not defined
/*because height was declared but not yet assigned
a value making the height variable a falsy 
value in an if else condition
*/
// updating the above variable
height = 50;
/*console logs variable is defined
hence turning it to a truthy value
 */
/* also if we declared height to be = to 
NaN, 0 , null and ' ' , the console will
reveal their Boolean type which is undoubtedly
falsy as listed earlier
*/

Before drawing curtains on this brief discuss, Let's have a sneak peek into Equality operators.

Equality operators in JavaScript are not something far fetched, they are no other duo

Than the (===) triple equality sign popularly known as strict equality comparison and the (==) equal equal operator which is ascribed with the role of type coercion (see previous lecture on data types).

To explain better, see the code nugget below

var height = 33
if (height === '33'){
  console.log('strict Operator at the wheel')
}else{
  console.log('equal equal operator took over')
}
/* here, console automatically prints the
first message because we're using the strict
operator which matches the value and data types
before determining the validity of the expression
*/
// on changing the condition of the if statement
i.e height == '33'
// console prints the second message.

To conclude with, Strict Operator ensure the matching of the value and type of the variable to be assigned before processing the logic.