Created by Maximilian Schwarzmüller
    Last Updated on April 15, 2020

    # JavaScript & Type Coercion

    In JavaScript, like generally in programming, you work with data - with values. And these values have different types. JavaScript requires certain types for certain operations and also freely converts between types. This can lead to unexpected behaviors - so here’s how JavaScript type coercion works (and what it is).

    In the above video, we explore why the following code works the way it does work:

    console.log([] == 0); // yields true!
    
    if ([]) {
      console.log('This executes!');
    }
    
    if (0) {
      console.log('This does NOT execute!');
    }
    
    // Why does the first 'if' statement run when the second one doesn't and [] == 0?