Course Content
Introduction to JavaScript
Data can be represented in different views. The operations that you do with data can be different for different data types.
Note
The Data Type is a type of information that tell to interpreter how to work with this data.
Let's look at the difference in interpreter behavior:
In the example, you can see that interpreter performs various operations for each data type.
typeof()
The typeof()
operator determines the data type. This operator returns a type of literal, variable, const, function, etc.
Number
The number is a data type used for calculation, counters, math operations, etc.
Unlike other programming languages, JavaScript uses the number type instead of the int and float types.
String
The string is a text data type. You should use the string data type if you need to work with text (change text, print text in the console, give a text to another program, etc.).
For every text information that you use in your code, you should write quotes ('some text'
or "some text"
). The interpreter knows that it is the text information, not a tool or another object.
Note
- Only one quote style (
"text"
or'text'
) should be used in your code (or project).- You can change the quote style when using
'
or"
in the text:"She hasn't hat"
or'He says "Hi!"'
Boolean
The boolean is a logical data type. Boolean has 2 values: true
and false
. Boolean is used to check conditionals that will be described later.
Boolean allows you to regulate the behavior of code execution and distribute it to different paths. Also, a boolean can use to turn on/off different tools and parameters.
To create a boolean value you should use the true
or false
literals (it's not keywords):
The true
and false
are ___.
Select the correct answer
What is the data type of the literal "number"
?
Select the correct answer
What is the data type of the literal 15
?
Select the correct answer
What is the data type of the literal 19.32
?
Select the correct answer
What is the data type of the literal true
?
Select the correct answer
Section 2.
Chapter 5