JavaScript
  Home arrow JavaScript arrow The Power of JavaScript: Operators
IBM Developerworks
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  
Dedicated Servers  
Download TestComplete 
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

The Power of JavaScript: Operators
By: Michael Youssef
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 13
    2005-07-19

    Table of Contents:
  • The Power of JavaScript: Operators
  • Arithmetic Operators
  • Comparison Operators
  • Increment and Decrement Operators

  • 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

    Anyone looking for a way to modernize legacy data or easily migrate to a more cost-effective database without sacrificing functionality will benefit from this seminar. View the Intro to Advantage Database Server now!

    The Power of JavaScript: Operators
    (Page 1 of 4 )

    We have discussed the very basics of Javascript. Until now, we have not written much code. There's still much more to knowing and learning to master the basics of Javascript. In this article, we talk about how we can perform arithmetic operations, comparison operations and increment/decrement operations using Javascript operators.

    Before we talk about operators, we must define what an expression is. An expression is a code snippet that yields a value. For example, the snippet 5 + "Five" is called an expression because the Javascript interpreter is able to evaluate it and produce a value (which is the string value "5Five"). We use expressions to build Javascript statements. We have said that a statement is very similar to a sentence in the English language in which it tells the interpreter to do something.

    In the expression 5 + "Five" we have not told the interpreter what to do yet with the value that it has produced, so we need to write a statement to the interpreter in order to execute it. The statement may look like this (for our example): var aString = 5 + "Five". Now the Interpreter understands that we need to concatenate the numerical value 5 with the string value "Five" and assign the resultant value to the variable aString.

    As you can see, we have used the plus symbol (which we call it the addition operator in Javascript) to write a somewhat complex expression. In fact a value like "hi" or 3 is considered an expression because the interpreter considers any code snippet that produces a value to be an expression. It happens that "hi" is a code snippet that produces a string value of "hi". We use operators like the addition operator to build complex expressions, so let's take a look at operators.

    An operator is a symbol with an associated known operation to the language. It works on one or more operands. Let's take the addition operator as an example. The + is a symbol, and the associated operation is adding two numerical values like 3 + 9; the numerical values are what we call the operator's operands. We can think of the operands as the values that the operator will work on, like 3 and 9.

    The addition operator is called a binary operator because it works on two operands. There are two more categories of operations. The unary operator has only one operand, and the ternary operator has three Operands (we will talk about such operators too). Now let's meet the first family of operators that we will discuss.

    More JavaScript Articles
    More By Michael Youssef


       · You write:ASCII values the upper-case letters have lower values than the...
       · You are right and sorry for the mistake.Thanks,Michael
     

    JAVASCRIPT ARTICLES

    - A Closer Look at Smart Markers with Yahoo! M...
    - Using Polylines and Smart Markers with Yahoo...
    - Bulleted Menu of Links
    - Creating Click Loggers and Basic Markers wit...
    - Adding Pan Controls to Yahoo! Maps
    - Adding Zoom Controls to Yahoo! Maps
    - Working with Yahoo! Maps
    - Building Image Zooming Controls with the DOM...
    - Working with Multiple Graphics for a Zoom Ap...
    - Improving an Image Zooming Application with ...
    - Zooming in on Images with JavaScript
    - JavaScript Date Objects: Universal Coordinat...
    - Javascript Objects: More Date Methods
    - JavaScript Objects: Dates
    - JavaScript Objects: Finishing Strings


     
    Accelerating Trading Partner Performance
     
    Competing on Analytics
     
    Cost Effective Scaling with Virtualization and Coyote Point Systems
     
    Five Checkpoints to Implementing IP Telephony
     
    Hosted Email Security: Staying Ahead of New Threats
     





    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway