Used to combine multiple conditions:

  • && (AND): Both conditions must be true.
  • || (OR): Either condition must be true.
  • ! (NOT): Reverses the truthiness of a condition.

Example:

JavaScript
let x = 10;
let y = 5;
let z = 15;

// && (AND): Both conditions must be true
if (x > y && z > x) {
    console.log("Both conditions are true."); // This will be printed
} else {
    console.log("One or both conditions are false.");
}

// || (OR): Either condition must be true
if (x > y || z < x) {
    console.log("At least one condition is true."); // This will be printed
} else {
    console.log("Both conditions are false.");
}

// ! (NOT): Reverses the truthiness of a condition
let isRaining = false;
if (!isRaining) {
    console.log("It is not raining."); // This will be printed
} else {
    console.log("It is raining.");
}