JavaScript
  Home arrow JavaScript arrow Page 5 - JavaScript Operators
Dev Articles Forums 
ADO.NET  
Apache  
ASP  
ASP.NET  
C#  
C++  
ColdFusion  
COM/COM+  
Delphi-Kylix  
Design Usability  
Development Cycles  
DHTML  
Embedded Tools  
Flash  
Graphic Design  
HTML  
IIS  
Interviews  
Java  
JavaScript  
MySQL  
Oracle  
Photoshop  
PHP  
Reviews  
Ruby-on-Rails  
SQL  
SQL Server  
Style Sheets  
VB.Net  
Visual Basic  
Web Authoring  
Web Services  
Web Standards  
XML  
Mobile Linux 
App Generation ROI 
IBM® developerWorks 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
JAVASCRIPT

JavaScript Operators
By: James Payne
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 3
    2007-11-05

    Table of Contents:
  • JavaScript Operators
  • Arithmetic Operators
  • Assignment Operators
  • Add and Assign
  • Comparison Operators
  • Logical Captain?

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    JavaScript Operators - Comparison Operators


    (Page 5 of 6 )

    In the hopes of not getting sued, I am going to create a fictional fast food restaurant. Let's say this fast food "restaurant" serves Mexican food (though in truth you would never find these things on the menu in Mexico). We'll give it a neat little name: Burrito Bell. So now let's say you went to this Burrito Bell and bought a taco for about 20 cents. Then you go to grocery store and buy a taco kit and ground beef and make your own taco and stand them side by side.

    The 20 cent taco looks nothing like your $3.00 homemade taco. Even the shells look different. The disturbing thing though is that when you look, smell, and taste the meat in the 20 cent taco you realize the creepy thing: that ain't hamburger beef. Hell, maybe it isn't beef period. I mean, what is that? Granted, you can't expect filet mignon in a 20 cent taco. But this stuff isn't even horse.

    Now mind you, I still eat at this theoretical Burrito Bell. I'm just saying when you compare real meat to the Burrito Bell meat, something isn't matching up.

    In JavaScript you can use Comparison Operators to compare values to one another. These are exceptionally handy when used in statements and loops (we will cover loops soon). But for now, let's work with a Boolean variable (boolean is a true/false, on/off, yes/no type of data).


    <HTML>

    <HEAD>

    <script type="text/Javascript">


    document.write(2 > 1)

    </SCRIPT>

    </HEAD>

    </HTML>

    The above would result in the following printing to your screen:

      True.

    What we have done is asked the computer to compare the values of 2 and 1. We stated that 2 was greater than 1 and asked the computer if this was true or false. The computer, being slightly smarter than you, told us it was True. Had we evaluated the statement 2 < 1, it would have returned a False response.

    More JavaScript Articles
    More By James Payne


       · In this article we discuss Javascript Operators and how to use them to manipulate...
     

    JAVASCRIPT ARTICLES

    - Using jQuery to Preload Images with CSS and ...
    - Using Client-Side Scripting to Preload Image...
    - Removing Non-Semantic Markup when Preloading...
    - Using the Display CSS Property to Preload Im...
    - Preloading Images with CSS and JavaScript
    - Scaling and Moving Web Page Elements with th...
    - Fading, Hiding and Sliding HTML Elements wit...
    - Toggling CSS Properties with the GX JavaScri...
    - Cancel, Queue and Pause Animations with the ...
    - Producing Elastic Effects with the GX JavaSc...
    - Moving Divs Diagonally with the GX JavaScrip...
    - Moving Elements Vertically and Horizontally ...
    - Making Bouncing Effects in Parallel with the...
    - Creating Bouncing Effects with the GX JavaSc...
    - Manipulating Background Colors with the GX J...







    © 2003-2010 by Developer Shed. All rights reserved. DS Cluster 5 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek