Skip to content

Logical operators

Overview

The operators available in Javascript are shown in the table below.

NameUsageEvaluates to
ANDa && btrue if a and b are both true, otherwise false
ORa || btrue if a is true or b is true (or both), otherwise false
NOT!athe opposite of a (false if a is true; true if a is false)

Using the operators

Here are some examples of using the operators:

js
const isBookAvailable = false
const hasOverdueBooks = true

console.log(!isBookAvailable) // NOT
console.log(isBookAvailable && hasOverdueBooks) // AND
console.log(isBookAvailable || hasOverdueBooks) // OR
console
true
false
true