

Logical NOT: true if the operand is false and vice-versa.Įxample 9: Logical AND Operator const a = true, b = false Ĭonsole.log((c > 2) & (c 2) || (c<2)) // true Logical OR: true if either of the operands/boolean values is true. Logical AND: true if both the operands/boolean values are true, else evaluates to false And = also checks for the data type while comparing. Here 2 and '2' are the same numbers but the data type is different. = evaluates to true if the operands are equal and of the same type. != evaluates to true if the operands are not equal.Įxample 3: Strict Equal to Operator const a = 2 If you mistakenly use = instead of =, you might get unwanted result.Įxample 2: Not Equal to Operator const a = 3, b = 'hello' Note: In JavaScript, = is a comparison operator, whereas = is an assignment operator. = evaluates to true if the operands are equal. Less than or equal to: true if the left operand is less than or equal to the right operandĮxample 1: Equal to Operator const a = 5, b = 2, c = 'hello' Less than: true if the left operand is less than the right operand Greater than or equal to: true if the left operand is greater than or equal to the right operand Greater than: true if the left operand is greater than the right operand Strict not equal to: true if the operands are equal but of different type or not equal at all Strict equal to: true if the operands are equal and of the same type Not equal to: true if the operands are not equal
