# 9 types of falsy values in JavaScript

You might have already come across (or may come across) the question below in a JavaScript/Frontend/Web Engineer interview.

**What are the possible outcomes of the given code snippet?**

```javascript
function greet(value) {
    if (value) {
        return "Hello, World!";
    }
    return value;
}
```

To answer the above question, you first need to understand what is considered falsy in JavaScript. Before continuing with the post, take a while and try to answer this by yourself. Let me know your answers in the comments below.

Falsy values in JavaScript -

1. **null**
    
    The null value represents the absence of any value.
    
    ```javascript
    Boolean(null)    // false
    ```
    
2. **undefined**
    
    The undefined property indicates that a variable has not been assigned a value, or not declared at all.
    
    ```javascript
    Boolean(undefined)    // false
    ```
    
3. **false**
    
    The boolean value.
    
4. **NaN**
    
    The global property that represents Not-A-Number.
    
    ```javascript
    Boolean(NaN)    // false
    ```
    
5. **0**
    
    The number zero (including 0.0, 0x0).
    
    ```javascript
    Boolean(0)    // false
    ```
    
6. **\-0**
    
    The number negative zero (including -0.0, -0x0)
    
    ```javascript
    Boolean(-0)    // false
    ```
    
7. **0n**
    
    The BigInt zero (including 0x0n). BigInt values represent numeric values which are too large to be represented by the number.
    
    ```javascript
    Boolean(0n)    // false
    ```
    
8. **""**
    
    The empty string value (including '' and \`\`).
    
    ```javascript
    Boolean("")    // false
    ```
    
9. **document.all**
    
    The only falsy object in JavaScript. This read-only property returns HTMLAllCollection rooted at the document node. This property is deprecated, some browsers might still support it.
    
    ```javascript
    Boolean(document.all)    // false
    ```
    

So in total there are **9 falsy** values in JavaScript and all other values are considered truthy.

**Answer to the above question -**

Above code snippet have **10** possible outcomes (**9 falsy** values and **"Hello, World!"** for all other values).
