JavaScript
  Home arrow JavaScript arrow Page 4 - The Power of Javascript: Basic Types of Da...
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: Basic Types of Data
By: Michael Youssef
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 3 stars3 stars3 stars3 stars3 stars / 22
    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
     
     
    ADVERTISEMENT


    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

    - Validating Digits and Dates with jQuery`s Va...
    - Validating Ranges, Emails, and URLs with jQu...
    - More Uses for the jQuery Tooltip Plug-in`s b...
    - Building Image-Based Tooltips with the jQuer...
    - Using the jQuery Tooltip Plug-in`s bodyHandl...
    - Using Rangelength, Min and Max with the Vali...
    - Using Minlength and Maxlength with the Valid...
    - Modifying Tooltip Coordinates with the jQuer...
    - Applying a Fade Out Effect with the jQuery T...
    - Tracking Mouse Movements with the jQuery Too...
    - Checking Online Forms with the Validator jQu...
    - Nested JavaScript Functions as Objects
    - The jQuery Tooltip Plug-in
    - Active Client Pages at the Server
    - ACP Tab Web Page







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