What are logical operators? I sometimes find this question asked online and thought it would be good to explore in today’s episode. There are only three and you might think you already know how to understand them. But have you heard of short circuit evaluations? If you don’t fully understand how logical operations can sometimes exit early, then at best, you’re going to write some inefficient code. And most likely, you’re going to introduce some hard to find bugs.

The AND operator is used to build up a series of terms or conditions that all have to be true in order for the entire series to be true.

The OR operator is similar except that only a single term needs to be true in order for the entire series to be true.

The NOT operator just switches a single term to the opposite value.

The episode also describes short circuit behavior. This allows the AND operator to return early when it finds the first term that’s false. The OR operator can return early when it finds the first term that’s true.