Advertisement
CR7CR7

logicalOperations

Sep 18th, 2022
515
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. let a = 6;
  2. let b = 7;
  3.  
  4. console.log(a >= b); // false
  5. console.log(a !== b); // true
  6.  
  7. let x = a > b; // false
  8. let y = b > a; // true
  9.  
  10. // true if both x and y are true, else false
  11. console.log(x && y); // false;
  12.  
  13. // true if at least one of x and y is true, else false
  14. console.log(x || y);
  15.  
  16. // negation, true if x is false, false if x is true
  17. console.log(!x);
  18.  
  19. // unlike other languages JavaScript doesn't have the XOR operator (true if only of the x and y is true, else false)
  20. // we can use an expression to achieve that
  21. console.log((x && !y) || (!x && y));
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement