Helping ordinary people create extraordinary websites!
GET OUR NEWSLETTER
Your Email:
 

Essential Javascript -- A Javascript Tutorial

By Patrick Hunlock
2007-12-02


Logical and Comparison Operators

Javascript supports equality checking (==) and identity checking (===). Equality checks for equality regardless of type. Therefore 25 and '25' will evaluate as true. Identity checking checks not only for equality but type equality as well so 25 and '25' will evaluate as false because, while both are 25, one is a string and the other a number. Note that a single equal sign is an assignment statement! x=5 will assign 5 to x, while x==5 will see if x is equal to 5, and x===5 will check to see if x is identical to 5.

In addition to == and ===, you can check for not equal (!=) and not identical (!==).

OperatorDescription
=Assignment x=5; // assigns 5 to x
==Equality, is x==5?
===Identity, is x 5 and a number as well?
!=Not equal, is x unequal to 5?
!==Not identical, is x unequal to the Number 5?
!Not, if not(false) is true.
||OR, is (x==5) OR (y==5)
&&And, is (x==5) AND (y==5)
<Less than. is x less than 5?
<=Less than or equal. is x less than or equal to 5?
>Greater than. is x greater than 5?
>=Greater than or qual. is x greater than or equal to 5?



Tutorial Pages:
» Essential Javascript -- A Javascript Tutorial
» Getting Started
» In-Line Javascript
» External Javascript
» Javascript is case sensitive
» Output (writeln)
» Output (alert)
» Output (getElementById)
» Input (One Click To Rule Them All)
» Input (User Input)
» Javascript is an Event Driven Language
» Comments
» Variables
» Variable Scope
» Special Keywords
» Arithmetic Operators
» Logical and Comparison Operators
» JavaScript Conditionals: IF
» JavaScript Conditionals: SWITCH
» JavaScript Conditionals: Shorthand Assignment
» JavaScript Conditionals: Ternary Operators
» JavaScript Loops: FOR
» JavaScript Loops: FOR/IN
» JavaScript Loops: WHILE
» Bringing It All Together
» DHTML: Dynamic HTML
» Conclusion


copyright © 2006, 2007 by Patrick Hunlock


 | Bookmark
Related Tutorials:
» JavaScript Debugging Techniques with Firebug
» Striped Tables Using JavaScript
» Opening PDFs in a New Window with JavaScript
» Submit Forms Conditionally using JavaScript
» How to Setup a Randomising Function
» Introduction to JavaScript Tutorial

Advertise with Us!


Tutorials Scripts Web Hosting Developer Manuals
Resources