Home arrow JavaScript arrow Page 5 - JavaScript Operators
JAVASCRIPT

JavaScript Operators


You can't do much with a programming language without operators. JavaScript is no exception. So this article will introduce you to JavaScript operators and what you can do with them.

Author Info:
By: James Payne
Rating: 4 stars4 stars4 stars4 stars4 stars / 3
November 05, 2007
TABLE OF CONTENTS:
  1. · JavaScript Operators
  2. · Arithmetic Operators
  3. · Assignment Operators
  4. · Add and Assign
  5. · Comparison Operators
  6. · Logical Captain?

print this article
SEARCH DEVARTICLES

TOOLS YOU CAN USE

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.


blog comments powered by Disqus
JAVASCRIPT ARTICLES

- More Top jQuery Tutorials for Beginners
- More Top jQuery Plugins for Menus
- Top jQuery Tutorials for Beginners
- New UI Framework and SDK for JavaScript Rele...
- JavaScript OpenPGP Tool, Node.js 0.6.3 Avail...
- Yahoo Releases Cocktails Language and Develo...
- Customizing jQuery Slideshows: Dynamic Contr...
- Customizing jQuery Slideshows: the animate()...
- Customizing jQuery Slideshows: slideUp() and...
- Customizing jQuery Slideshows: hide() and sh...
- Web Workers: Performing Calculations in Para...
- More Top JavaScript Frameworks and Libraries
- More Dynamic jQuery Styling Techniques
- The Top JavaScript Libraries
- The Top JavaScript Frameworks

Dev Articles Forums 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Weekly Newsletter
 
Developer Updates  
Free Website Content 
Contact Us 
Site Map 
Privacy Policy 
Support 



© 2003-2012 by Developer Shed. All rights reserved. DS Cluster 11 - Follow our Sitemap
Popular Web Development Topics
All Web Development Tutorials