JavaScript
  Home arrow JavaScript arrow Page 3 - The Power of Javascript: Operators conclud...
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 
Sun Developer Network 
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 concluded
By: Michael Youssef
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 6
    2005-08-02

    Table of Contents:
  • The Power of Javascript: Operators concluded
  • Logical Operators Example
  • The Operator typeof
  • The Void Operator
  • Operator Precedence and Associativity

  • 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 concluded - The Operator typeof


    (Page 3 of 5 )

    The typeof Operator (written in lower case because Javascript is case-sensitive) is a special type of operator that we have not discussed yet. For now we can say that not all operators are symbols, and typeof is one example of that. The typeof operator returns the data type of its operand, but to use it you must place the operand between parentheses (we will talk about parentheses use throughout the series so don't worry about what it means right now) like this: typeof(operand) as in the following example.

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">
    <html>
      <head>
        <title>Hello World</title>
        <script language="JavaScript" type="text/javascript">
          var aNumber = 1;
          var aString = "I'm a string";
          var aBoolean = true;

          document.write("aNumber data type = " + typeof(aNumber) + "<br>");
          document.write("aNumber data type = " + typeof(aString) + "<br>");
          document.write("aNumber data type = " + typeof(aBoolean)+ "<br>"); 
        </script>
      </head>
      <body>
      </body>
    </html>

    When you save and load this code in your browser you will get the following text written to the Web page.

    As you guessed the expressions typeof(aNumber), typeof(aString) and typeof(aBoolean) just return the data type of the operand (the variable result) of the typeof Operator. Note that the typeof Operator returns two more data types (object and function) but we will talk about that when the time comes.

    More JavaScript Articles
    More By Michael Youssef


     

    JAVASCRIPT ARTICLES

    - Using Click Interceptions with a Database-Dr...
    - Using JavaScript Click Interceptions in an I...
    - Using Click Interceptions with JavaScript
    - QuickSort in Action
    - Quicksort
    - Using Mod_Security to Protect Your Server
    - Detecting and Countering Server Intrusions
    - Securing Your Web Server
    - Building a Secure Web Server
    - Protecting the Server
    - Book Review: Learning the Yahoo! User Interf...
    - Dynamically Generate a Selection List in a R...
    - Intergrate DWR into Your Java Web Application
    - Detect Browser Compatibility with the Reques...
    - Using the EXT JS Date Picker Widget






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