JavaScript Logical Operators (and Boolean)

  • && (AND)
  • || (OR)
  • ! (NOT)
If you were to find out if two values were true or false, you would use AND. 

For something to be true, both the values would have to be true. 

For example, requesting if:

true && true = true
true && false = false
false && false = false 

|| (OR) is requesting if one of the values is true. For example: 

true || fsadf = true
false || true = true
false || false = false 

! (NOT) is a negation, so requesting if:
!true = false (something not true is false)
!false = true (something not false is true)

You can also combine logical operators.  For example:
 !(true && true) = false (because true AND true is true, and negating it is false) 

For more on operators, go to https://jamesymcjamesface.blogspot.com/2020/04/javascript-operators.html

No comments:

Post a Comment

Web Development: Organizing Files and Folders

When you begin to build your website, it's a very clever idea to organize  your files and folders efficiently. You should have: A ...