JavaScript
  Home arrow JavaScript arrow Page 4 - The Power of Javascript: Basic Types of Da...
Web Buyers Guide
The Best Selling PC Migration Utility.
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: Basic Types of Data
By: Michael Youssef
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 3 stars3 stars3 stars3 stars3 stars / 19
    2005-07-12

    Table of Contents:
  • The Power of Javascript: Basic Types of Data
  • Data as Numbers
  • Boolean Data, Yes or No
  • One Small Change

  • 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
     
     
    Iron Speed
     
    ADVERTISEMENT

    TestComplete™ automates software testing for a fraction of what the big guys charge. Easy functional and load testing for all Windows, .NET, Java and Web apps. Download a free trial now.

    The Power of Javascript: Basic Types of Data - One Small Change
    (Page 4 of 4 )

    As you can see, the <br> tags are included inside the message boxes. Before we leave this section we will use something that is similar (in functionality) to the <br> tag that the message box will understand. Replace the code with the following:

    <!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;
    alert("The variable aNumber = \n"+ aNumber);
    aNumber = 123;
    alert("The variable aNumber = \n"+ aNumber);
    aNumber = "I'M NEW TO JAVASCRIPT";
    alert("The variable aNumber = \n"+ aNumber);
    </script>
    </head>
    <body>
    </body>
    </html>

    Save and load the page, you will get the following three message boxes:

    What we have done here is that we used the new line escape character, which the message box understands. We have placed the new line after the = sign in the string value, so the value of the variable aNumber prints at the next line. There's another thing that I would like to tell you in the following code:

    aNumber = 123;
    alert("The variable aNumber = \n"+ aNumber);

    The first statement assigns the value 123 to the variable aNumber, and it should be familiar to you by now. The next statement concatenates the string value "The variable aNumber\n" with the number value 123, so the interpreter converts aNumber's value to a string value of "123" then concatenates it to the value:

    "The variable aNumber = \n"

    Then it displays the result. That's enough for now; we will talk about data type conversion in its own article.


    DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware.

     

    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

    Iron Speed

     
    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 6 hosted by Hostway