top of page
Writer's picture_Romeyo Boy_

JavaScript : Comparison Operator



Comparison operators are used in logical statements to determine the similarity or difference between variables or values.


<> Code Example :


  • == True if x is equal to y.

  • === True if x is equal to y, and they are of the same type.

  • != True if x is not equal to y.

  • !=== True if x is not equal to y, or they are not of the same type.

  • < True if x is smaller than y.

  • > True if x is greater than y.

  • >= True if x is greater than or equal to y.

  • <= True if x is less than or equal to y.


<> Code Example:




We can use comparison operators or comparison operators in logical statements to find out whether variables or values are different.


You either get true or false.


For example, the equals (==) operator checks whether the values of the operands are equal.


<> Code Example :

Conscious! - You can compare all types of data with comparison operators, they always return true or false.


Check out this table to see an analysis of comparison operators.

Operators

Description

उदाहरण

परिणाम

==

Equal to

5 == 10

false

===

Identical (equal and of same type)

5 === 10

false

!=

Not equal to

5 != 10

true

!==

Not Identical

10 !== 10

false

>

Greater Than

10 > 5

true

>=

Greater than or equal to

10 >= 5

true

<

Less Than

10 < 5

false

<=

Less than or equal to

10 <= 5

​false

Conscious! - When we use operators, one important thing to remember is that they only work. when they are comparing the same data type; Numbers with numbers, string with strings, you get the idea.





1 view0 comments

Recent Posts

See All

Comments


bottom of page