Logical Operators in JavaScript

Logical Operators
  • *NOTE — if the first expression is false the && operator will return the first expression without ever checking the second expression.
  • If both expressions are truthy then the engine will check the first expression and then follow with second and return the second expression.
  • **NOTE — If the first expression is true, then the value is immediately returned and the second expression is never even evaluated
  • If the first expression is false, then the OR operator returns whatever the second expression evaluates to


The best way to understand the concepts is to play around with the operators in the console itself. The logical operators in JavaScript are very powerful. Once you understand how to use them correctly, they are MAGIC!



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store