The Power of Javascript: Basic Types of Data (Page 1 of 4 )
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.
We are still at the stage of examining basic concepts in Javascript. In this article we are going to learn about the basic types of data that Javascript interpreters understand and manipulate. Programming languages differentiate between the various data we store and manipulate. To help you understand what I mean, suppose that we need to add two values and store the result in a variable. These values may be one of the following pairs:
45, 87
or
"Hello", 23
or
"Hi", "Name"
So when we use the plus symbol (which is called an operator in Javascript, and will be discussed with the other available operators in the following articles) with the first pair ( 45 + 87 ), Javascript understands that we are performing an addition operation on numbers. When we use the plus symbol with the third pair (the characters text), it understands that we need to perform an operation called concatenation, which produces a text of the first value and the second value together. If we concatenate "Hi" + "Name" it produces one text, "HiName."
We will talk more about the double quotes and why we put them in, but for now we need to understand that programming languages must differentiate between numbers and text because, as you will see in this article, the operations (like the addition operation) produce different values depending on the type of data we are dealing with (numbers or text), which are called basic data types because they are the simplest form of data that we can manipulate. The second pair is discussed with an example in this article because it's an interesting example for a Javascript beginner.
Next: Data as Numbers >>
More JavaScript Articles
More By Michael Youssef