course content

Course Content

Introduction to JavaScript

Data Types OverviewData Types Overview

Data can be represented in various ways, and the operations you perform on data can differ depending on the data types.

Note

The Data Type tells the interpreter how to work with the data.

Let's look at the difference in the interpreter behavior:

In the example above, you can see that the interpreter performs different operations for different data types.

typeof()

The typeof() operator returns a string indicating the type of the operand's value.

Number

The number data type is used for calculations, counters, mathematical operations, and more.

Unlike other programming languages, JavaScript uses the number type instead of separate int and float types.

Note

The typeof operator only determines the data type of the result, not the performed operations.

String

The string data type is used to change, print, and pass text to other programs.

To identify the string in the code, we should use single or double quotes (e.g., 'some text' or "some text")

Note

  • Choose one quote style ("text" or 'text') for your code or project.
  • You can switch between quote styles when using ' or " within the text, such as "She hasn't hat" or 'He says "Hi!"'

Boolean

The boolean data type is used for logical operations. It has two values: true and false. Booleans are used to check conditions, as we'll describe later.

Booleans allow you to control code execution and direct it along different paths.

To create a boolean value, use the true or false values:

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

question-icon

The true and false are ___.

Select the correct answer

question-icon

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

Select the correct answer

question-icon

What is the data type of the value 15?

Select the correct answer

question-icon

What is the data type of the value 19.32?

Select the correct answer

question-icon

What is the data type of the value true?

Select the correct answer

question-icon

Drag values to their types.

string:

number:


boolean:

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

Everything was clear?

Section 2. Chapter 4