Operators: ========== Decrement Operators: =================== -- Can decrease the value by '1' ==> can define in two ways: 1) Pre-Decrement Operator 2) Post-Decrement Operator Pre-Decrement Operator ====================== Syntax: --operand 1) Decrease the value by '1' 2) Assignment Post-Decrement Operator ======================= Syntax: operand-- 1) Assignment 2) Decrease the value by '1' // Pre-Decrement Operation var a = 100; console.log("the value of a = "+a); --a; console.log("The value of a after the pre-decrementation = "+a); const b = --a; console.log("value of a = "+a+" value of b = "+b); a--; console.log("a = "+a); let c = a--; console.log("value of a = "+a+" value of c = "+c); ==================================== a = 10 a++ + ++a - a-- + --a 10 + 12 - 12 + 10 22 - 12 + 10 10 + 10 20 a = 11 a = 12 a = 11 a = 10 0 + 0 - 0 + 0 9 + 9 - 9 + 9 18 - 9 + 9 9 + 9 18 a = 9 a = 8 a = 9 a = 10 ++, -- ==> Higher order +, - ==> Lower Order a = 0 a = -1 a = 0 a = 1 ================================== Relational Operators: ===================== ==> Comparison Operators ==> return values: Boolean values (true/false) < ==> less than > ==> grater than <= ==> less than or equals to >= ==> greater than or equals to x, y and z x with y x with z y with z let a = 10; let b = 20; console.log("a is less than b :"+(a < b)); console.log("a is greater than b :"+(a > b)); console.log("a is less than or equal to b :"+(a <= b)); // <= ==> a < b or a == b console.log("a is greater than or equal to b :"+(a >= b)); console.log((a + b - 2) == (a -b + 2)); ====================================================== Logical Operators: ================== ==> three: 1) Logical and ==> && 2) Logical or ==> || 3) Logical not ==> ! Note: ==== we can use the logical operators with any value. a b a && b a || b !a !b =========================================================== true true true true false false true false false true false true false true false true true false false false false false true true Note: ===== 1) When the first input (left hand side) is true (non-zero) logical and (&&) can return an output ==> second operand value 2) When the first input is false/0 output ==> false/0 console.log(true && true); console.log(true && false); console.log(false && true); console.log(false && false); console.log(100 && 200); // 200 console.log(0 && 100); // 0 console.log(-1 && -2); //-2 console.log(100 && -1); //-1 console.log(-100 && 0); console.log(-100 && false); console.log(-100 && true); ========================== console.log(true || true); console.log(true || false); console.log(false || true); console.log(false || false); // if first input ==> true/non-zero, output ==> true/non-zero (first operand) (without decoding the second operand) console.log(true || 100); console.log(100 || true); // if the first input ==> false/0, output ==> second operand console.log(0 || 100); console.log(false || 0); ========================================= console.log(!true); console.log(!false); console.log(!100);