The Basics:

# Truthy & Falsy

In most programming languages, as well as in math, the concept of true and false is completely binary: Either something is true, otherwise it's false. But in JavaScript, the concept of true and false is expanded a bit, because the language is generally quite loose and not as strict as other programming languages.

In practice this means that sometimes JavaScript will evaluate something to either true or false, despite the fact that it's not completely true or false. The purpose is simply to make things easier and less complicated for you, but if you don't know about this, or if you forget it for a moment, things might get a bit confusing.

So, allow me to introduce a new concept for you: Truthy and Falsy. They exist only as concepts - you won't find keywords for them in JavaScript, nor will you be able to check against a truthy or falsy value. Instead, JavaScript has introduced a second set of operators for checking whether something is completely true or completely false. These are referred to as strict operators, e.g. the strict equality operator, where we use three equal signs instead of two, when comparing two values.

We will talk much more about the various operators of JavaScript, including the strict ones, in an upcoming chapter, but for now, let's talk more about what can be considered Truthy or Falsy.

## Truthy

In JavaScript, all values are Truthy unless they are specifically Falsy. JavaScript will use type coercion to convert something to a boolean value when used in a context which requires it, like a loop or an if statement. For instance, consider the following examples of values that will be treated as true because they are Truthy:

``````if(true)
if(42)
if("hello world")

If you run this example, you will see that all three if statements evaluate to true, but why is "hello world" true? Because it contains an actual value and therefore, JavaScript will consider this truthy when used in a context where true or false is required.

## Falsy

In general, all values that are either null, undefined or empty will be considered as Falsy and therefore be treated as false, when used in a boolean context like loops and if statements. Here's a couple of examples:

``````if(false)
if(null)
if(0)