JavaScript Control Flow Conditionals

So far, we've covered JavaScript data types, variables, constants and functions, but there's still something missing from the puzzle. We have yet to learn how to conditionally execute code.

This is not an oversight. Imperative conditional code is easy to write but hard to reason about, which is why we recommend turning to concepts learned in this lesson as a sort of last resort. That is not to say that we should avoid using imperative conditionals like the if statement; sometimes they are the right tool for the job.

In many places we can chain Boolean logical operators, use truthiness of values and take advantage of short-circuiting to write what often is better code.

Without further ado, let us learn about one of the most powerful tools in the JavaScript language: conditionals.