www.pickatutorial.com Computer Tutorials
Top eBooks: C/C++ | C# | Android | Mathematics | Database | Cloud | Graphics | Networking | Oracle | Hardware | AI
Top Tutorials: C/C++ | C#.NET | PHP MySQL | Java | Java Script | jQuery | HTML | xHTML | HTML5 | VB Script| CSS
Lessons JavaScript Comparison Operators Bookmark and Share
Tutorial Home
Lesson 1
Lesson 2
Lesson 3
Lesson 4
Lesson 5
Lesson 6
Lesson 7
Lesson 8
Lesson 9
Lesson 10
Lesson 11
Lesson 12
Lesson 13
Lesson 14
Lesson 15
Lesson 16
Lesson 17
Lesson 18
Lesson 19
Lesson 20
Lesson 21
Lesson 22
Lesson 23
Lesson 24
Lesson 25
Lesson 26
Lesson 27
Lesson 28
Lesson 29
Lesson 30
Lesson 31
Lesson 32
Lesson 33
Lesson 34
Lesson 35
Lesson 36
Lesson 37
Lesson 38
Lesson 39
Lesson 40
Lesson 41
Lesson 42
Lesson 43
Lesson 44
Lesson 45
Lesson 46
Lesson 47
Lesson 48
Lesson 49

A comparison operator compares its operands and returns a logical value (true or false) based on whether the comparison is true or not. The operands could be numeric, text, or object values. The Text or strings are compared based on standard lexicographical ordering, based on Unicode values.

For the cases when the two operands are not of the same type, JavaScript converts them to an appropriate type and then compares the both. The following table describes the different comparison operators available in JavaScript:

Operator Description Example
== checks for the equality of the operands 5==3 returns false
=== checks for the equality both in terms of values and types of the operands a=4
b="6"

a==b returns true
a===b returns false (as the data type of both the operands is not the same i.e the first variable is of a numeric type, while the second one is of type string)

!= checks for the inequality of the operands 2!=8 returns true
> checks if the left hand side value is greater than the value on the right hand side 5>8 returns false
< checks if the left hand side value is less than the value on the right hand side 5<8 returns true
>= checks if the value on the left hand side is greater than or equal to the value on the right hand side 5>=8 returns false
<= checks if the value on the left hand side is less than or equal to the value on the right hand side 5<=8 returns true

Next >>> Lesson No. 9: Switch Statement





Home - Advertise - Contact - Disclaimer - About Us
© Since 2006 pickatutorial.com -- All Rights Reserved.