JavaScript: Logical Comparisons Flashcards
Arithmetic Operators
Combine with numbers to form an expression that returns a single number.
console.log(a + b);
console.log(a - b);
console.log(a / b);
console.log(a * b);
Modulus Operator %
Returns the remainder between two numbers.
console.log(a % b);
Comparison Operators: == and !==
Comparison operators combine with strings, booleans and numbers to form an expression that evaluates to true or false.
Compares equality of value, not data type.
console.log(b == c);
console.log(b != c);
Comparison Operators: === and !===
Compares equality AND data type (strict equality)
console.log(b === c);
console.log(b !== c);
Comparison Operators: <, >, <=, and >=
< and > : Greater than or less than
console.log(a > b);
console.log(a < b);
<= and >= : Greater than or equal to and less than or equal to
console.log(a >= b);
console.log(a <= b);
Comparison Operators: &&
Evaluates to true if expression1 AND expression2 are both true, otherwise false.
console.log(expression1 && expression2);
Comparison Operators: ||
Evaluates to true if expression1 OR expression2 is true, otherwise false.
console.log(expression1 || expression2);
Logical Not (!)
Logical Not (!) turns an expression that evaluates to true to false and vice versa.
If expression2 is true, the following would return as false:
console.log(!expression2);