course content

Course Content

Introduction to JavaScript

Data Types OverviewData Types Overview

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):

1. The `true` and `false` are ___.
2. What is the data type of the literal `"number"`?
3. What is the data type of the literal `15`?
4. What is the data type of the literal `19.32`?
5. What is the data type of the literal `true`?
6. Drag literals to their types.

question-icon

The true and false are ___.

Select the correct answer

question-icon

What is the data type of the literal "number"?

Select the correct answer

question-icon

What is the data type of the literal 15?

Select the correct answer

question-icon

What is the data type of the literal 19.32?

Select the correct answer

question-icon

What is the data type of the literal true?

Select the correct answer

question-icon

Drag literals to their types.

string:
_ _ _


number:
_ _ _


boolean:
_ _ _

Click or drag`n`drop items and fill in the blanks

dots
175.23
dots
"word"
dots
while
dots
let
dots
false

Section 2.

Chapter 5