Arithmetic Operators Comparison (Relational) Operators Logical Operators Bitwise Operators Assignment Operators
Arithmetic Operators
Arithmetic operators perform addition, subtraction, multiplication, division, exponentiation, and modulus operations.
Operators Meaning Example Result + Addition 4+2 6 – Subtraction 4-2 2 * Multiplication 4*2 8 / Division 4/2 2 % Modulus operator to get the remainder in integer division 5%2 1 ++ Increment A = 10; A+ + 11 — Decrement A = 10; A− − 9
Relational Operators
Operators Meaning Example Result < Less than 5<2 False > Greater than 5>2 True <= Less than or equal to 5<=2 False >= Greater than or equal to 5>=2 True = Equal to 5==2 False != Not equal to 5! =2 True === Equal value and same type 5 === 5 5 === “5” True False !== Not Equal Value or Not same type 5 ! == 5 5 ! == “5” False True
Logical Operators
Operators Meaning Example Result && Logical and (5<2)&&(5>3) False || Logical or (5<2)||(5>3) True ! Logical not !(5<2) True
&&
Operand 1 Operand 2 Result True True True True False False False True False False False False
||
Operand 1 Operand 2 Result True True True True False True False True True False False False
!
Operand Result False True True False
Bitwise Operators
Operator Meaning << Shifts the bits to left >> Shifts the bits to the right ~ Bitwise inversion (one‟s complement) & Bitwise logical AND | Bitwise logical OR ^ Bitwise exclusive or
Bitwise logical AND &
Operand 1 Operand 2 Result (operand1&operand2) True True True True False False False True False False False False
Operand 1 Operand 2 Result (operand1&operand2) 1 1 1 1 0 0 0 1 0 0 0 0
Bitwise logical OR |
Operand 1 Operand 2 Result (operand1|operand2) True 1 True 1 True 1 True 1 False 0 True 1 False 0 True 1 True 1 False 0 False 0 False 0
Bitwise XOR ^
Operand 1 Operand 2 Result (operand1^operand2) True 1 True 1 False 0 True 1 False 0 True 1 False 0 True 1 True 1 False 0 False 0 False 0
Bitwise NOT ~
Operand Result True 1 False 0 False 0 True 1
Assignment Operators
Operator Example Equivalent Expression = 𝑚 = 10 𝑚 = 10 += 𝑚 += 10 𝑚 = 𝑚 + 10 −= 𝑚 −= 10 𝑚 = 𝑚 − 10 ∗= 𝑚 ∗= 10 𝑚 = 𝑚 ∗ 10 / = 𝑚 / = 𝑚 = 𝑚/10 % = 𝑚 % = 10 𝑚 = 𝑚%10 <<= 𝑎 <<= 𝑏 𝑎 = 𝑎 << 𝑏 >>= 𝑎 >>= 𝑏 𝑎 = 𝑎 >> 𝑏 >>>= 𝑎 >>>= 𝑏 𝑎 = 𝑎 >>> 𝑏 & = 𝑎 & = 𝑏 𝑎 = 𝑎 & 𝑏 ^ = 𝑎 ^ = 𝑏 𝑎 = 𝑎 ^ 𝑏 | = 𝑎 | = 𝑏 𝑎 = 𝑎 | b
Tagged : Assignment operators / Javascript / php Logical operators