DEV Community

R.Shobika CSE
R.Shobika CSE

Posted on

COMPARISON OPERATOR

COMPARISON OPERATOR

This operator is used for to compare two values . Comparison operator always return true or false. There are various type [==, <, >, <=, >=, ===, !=, !==]

1. ==

This operator is used for to compare two value if right side and left side values are same means it return true otherwise return false.

10==10
Enter fullscreen mode Exit fullscreen mode

output:true

10==5
Enter fullscreen mode Exit fullscreen mode

output:false

10=="10"
Enter fullscreen mode Exit fullscreen mode

output:true

2.===

This operator is used for to compare both the same value and also their datatype

10===10
Enter fullscreen mode Exit fullscreen mode

output:true

10==="10"
Enter fullscreen mode Exit fullscreen mode

output:false

3.<

This operator is used to find the value is less than or not is compare to the given value

10<5
Enter fullscreen mode Exit fullscreen mode

output:false

10<12
Enter fullscreen mode Exit fullscreen mode

output:true

4.>

This operator is used to find the value is greater than or not compare to the given value

5>10
Enter fullscreen mode Exit fullscreen mode

output:false

5.<=

This operator is used to find the value is less than or equal to is compare to the given value if it is not less than or not equal to means it returns false

10<=10
Enter fullscreen mode Exit fullscreen mode

output:true

6.>=

This operator is used to find the value is greater than or equal to is compare to the given value if it is not greater than or not equal to means it returns false

11>=10
Enter fullscreen mode Exit fullscreen mode

output:true

7.!=

This operator is not equal to if the two value is not equal to means it returns true otherwise it return false

10!=10
Enter fullscreen mode Exit fullscreen mode

output:false

10!=5
Enter fullscreen mode Exit fullscreen mode

output:true

8.!==

This operator is not double equal to this operator is used to check the value is not equal and its check their data type also

10!=="10"
Enter fullscreen mode Exit fullscreen mode

output:false

LOGICAL OPERATOR

Logical operators are used to combine boolean expressions. there are two type [&&,||]

1. &&

This operator is *AND * operator when both side condition is true means it return true otherwise if any one condition id false means the result is false.

Quick Remember
False False = False
False True = False
True False = False
True True = True

2.||

This operator is OR operator if any one condition is true means it return true otherwise it return false

Quick Remember
False False = False
False True = True
True False = True
True True = True

Top comments (0)