JavaScript
  Home arrow JavaScript arrow The Power of 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

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


    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

    - Building Dynamic Shadows with JavaScript and...
    - Active Client Pages: Chrys`s Approach
    - The Script Approach to Active Client Pages: ...
    - Principles of Active Client Pages: the Scrip...
    - Active Client Pages: the Script Approach
    - Building an RTF-capable Form with the Ext JS...
    - Creating a Multi-Tabbed Online Form with the...
    - jQuery Overview
    - Constructing a Multi-Column Online Form with...
    - Grouping Field Sets on Dynamic Web Forms wit...
    - Building Dynamic Web Forms with the Ext JS F...
    - More on JavaScript Array Objects
    - Methods of the DOM Location Object
    - The DOM Location Object Properties
    - Handling Remote Files with JavaScript Click ...







    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway
    Stay green...Green IT