Java Reference
In-Depth Information
2
Data Types and Variables
One of the main uses of computers is to process and display information. By processing, we mean
the information is modifi ed, interpreted, or fi ltered in some way by the computer. For example,
on an online banking web site, a customer may request details of all moneys paid out from his
account in the last month. Here the computer would retrieve the information, fi lter out any infor-
mation not related to payments made in the last month, and then display what's left in a web
page. In some situations, information is processed without being displayed, and at other times,
information is obtained directly without being processed. For example, in a banking environment,
regular payments may be processed and transferred electronically without any human interaction
or display.
In computing, information is referred to as data . Data come in all sorts of forms, such as numbers,
text, dates, and times, to mention just a few. In this chapter, you look specifi cally at how JavaScript
handles data such as numbers and text. An understanding of how data are handled is fundamen-
tal to any programming language.
The chapter starts by looking at the various types of data JavaScript can process. Then you look at
how you can store these data in the computer's memory so you can use them again and again in
the code. Finally, you see how to use JavaScript to manipulate and process the data.
Types of Data in JavaScript
Data can come in many different forms, or types . You'll recognize some of the data types that
JavaScript handles from the world outside programming — for example, numbers and text. Other
data types are a little more abstract and are used to make programming easier; one example is the
object data type, which you won't see in detail until Chapter 4.
Some programming languages are strongly typed. In these languages, whenever you use a piece
of data, you need to explicitly state what sort of data you are dealing with, and use of those data
must follow strict rules applicable to its type. For example, you can't add a number and a word
together.
Search WWH ::




Custom Search