Home arrow JavaScript arrow Page 4 - The Power of Javascript: Basic Types of Data

The Power of Javascript: Basic Types of Data

Javascript interpreters understand two different, basic types of data: numbers and character strings. But interpreters only understand these data types when they are presented in certain ways. This article, the third in a series, will explain what these types of data are, and how to handle them.

Author Info:
By: Michael Youssef
Rating: 4 stars4 stars4 stars4 stars4 stars / 30
July 12, 2005
  1. · The Power of Javascript: Basic Types of Data
  2. · Data as Numbers
  3. · Boolean Data, Yes or No
  4. · One Small Change

print this article

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"
<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);
alert("The variable aNumber = \n"+ aNumber);

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.

blog comments powered by Disqus

- Project Nashorn to Make Java, JavaScript Wor...
- JavaScript Virus Attacks Tumblr Blogs
- Google Releases Stable Dart Version, JavaScr...
- Khan Academy Unveils New JavaScript Learning...
- Accessing Nitro? There`s an App for That
- JQuery 2.0 Leaving Older IE Versions Behind
- Fastest JavaScript Engine Might Surprise You
- Microsoft Adjusting Chakra for IE 10
- Brendan Eich: We Don`t Need Google Native Cl...
- An Overview of JavaScript Statements
- An Overview of JavaScript Operators
- Overview of JavaScript Variables
- More of the Top jQuery Social Plugins
- The Top jQuery Social Plugins
- More of the Top jQuery Slider Plugins

Watch our Tech Videos 
Dev Articles Forums 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us 
Weekly Newsletter
Developer Updates  
Free Website Content 
Contact Us 
Site Map 
Privacy Policy 

Developer Shed Affiliates


© 2003-2019 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap
Popular Web Development Topics
All Web Development Tutorials