JavaScript Comparison Operators


JavaScript Comparison Operators
If you want to compare a variable with other variable in JavScript you can use Comparison Operators. Here is list of Comparison Operator (with x = 7) :

== To compare two values and verifying similarity
Example: x == 3 return the value True, if x is equal to 3, otherwise the value False

=== To verify the identity of the two values and the type of the two values are equal
Example: a === b returns True if a value equal to b, and have the same type, otherwise the value False

!= To verify whether a different variable with a value
Example: x! = 3 returns the value 1, if x is not the same (different) with 3, otherwise the value 0

!== To verify whether two values are not worth as much or is not the same kind
Example: A! == b returns True, if a different from b or a different type, otherwise the value False

< To verify whether one value is smaller than another value
Example: x <3 returns True if x is less than 3, otherwise the value False

<= To verify whether a value less than or equal to another value
Example: x <= 3 returns True if x is less than or equal to 3, otherwise the value False

> To verify whether one value is greater than another value
Example: x> 3 returns True if x is greater than 3, otherwise the value False

>= To verify whether a value greater than or equal to another value
Example: x> = 3 returns True if x is greater than or equal to 3, otherwise the value False

0 comments:

Post a Comment