Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Learn Exploring JavaScript Data Types | Variables and Data Types in JavaScript
Practice
Projects
Quizzes & Challenges
Quizzes
Challenges
/
Introduction to JavaScript

bookExploring JavaScript Data Types

Different kinds of data behave differently in JavaScript, so understanding data types is essential.

Note
Note

A data type tells JavaScript how to treat a piece of data.

Different Types β†’ Different Results

12345
// Strings console.log("123" + "123"); // Numbers console.log(123 + 123);
copy

The interpreter performs string concatenation in the first case and addition in the second.

typeof Operator

typeof returns the type of a value:

1234567
let a = 15; console.log(typeof 23); // number console.log(typeof a); // number const b = "today"; console.log(typeof "word"); // string console.log(typeof b); // string
copy

Core JavaScript Data Types

Number

Used for calculations, counters, and math. JavaScript uses a single number type (no separate int/float).

12345
console.log(typeof 15.25); console.log(typeof 211); console.log(typeof (22 + 251)); console.log(typeof (26 / 342));
copy

String

Used to store and work with text. Strings must be wrapped in single or double quotes.

12
let str = "Hello! I'm String, and I should help you to work with text!"; console.log(str);
copy

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

1234567
console.log("text"); console.log('text'); console.log("console.log('text')"); console.log('console.log("text")'); console.log(typeof("10"));
copy
Note
Note

Stick to one style of quotes per project, but switch when needed inside the text.

Boolean

Represents logical values: true or false. Used to check conditions and control program flow.

12345678
console.log(true); console.log(false); console.log(typeof(true)); console.log(typeof(false)); console.log(25 > 15); console.log(15 > 25);
copy

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 mark

The true and false are ___.

Select the correct answer

question mark

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

Select the correct answer

question mark

What is the data type of the value 15?

Select the correct answer

question mark

What is the data type of the value 19.32?

Select the correct answer

question mark

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?

How can we improve it?

Thanks for your feedback!

SectionΒ 2. ChapterΒ 4

Ask AI

expand

Ask AI

ChatGPT

Ask anything or try one of the suggested questions to begin our chat

bookExploring JavaScript Data Types

Swipe to show menu

Different kinds of data behave differently in JavaScript, so understanding data types is essential.

Note
Note

A data type tells JavaScript how to treat a piece of data.

Different Types β†’ Different Results

12345
// Strings console.log("123" + "123"); // Numbers console.log(123 + 123);
copy

The interpreter performs string concatenation in the first case and addition in the second.

typeof Operator

typeof returns the type of a value:

1234567
let a = 15; console.log(typeof 23); // number console.log(typeof a); // number const b = "today"; console.log(typeof "word"); // string console.log(typeof b); // string
copy

Core JavaScript Data Types

Number

Used for calculations, counters, and math. JavaScript uses a single number type (no separate int/float).

12345
console.log(typeof 15.25); console.log(typeof 211); console.log(typeof (22 + 251)); console.log(typeof (26 / 342));
copy

String

Used to store and work with text. Strings must be wrapped in single or double quotes.

12
let str = "Hello! I'm String, and I should help you to work with text!"; console.log(str);
copy

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

1234567
console.log("text"); console.log('text'); console.log("console.log('text')"); console.log('console.log("text")'); console.log(typeof("10"));
copy
Note
Note

Stick to one style of quotes per project, but switch when needed inside the text.

Boolean

Represents logical values: true or false. Used to check conditions and control program flow.

12345678
console.log(true); console.log(false); console.log(typeof(true)); console.log(typeof(false)); console.log(25 > 15); console.log(15 > 25);
copy

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 mark

The true and false are ___.

Select the correct answer

question mark

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

Select the correct answer

question mark

What is the data type of the value 15?

Select the correct answer

question mark

What is the data type of the value 19.32?

Select the correct answer

question mark

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?

How can we improve it?

Thanks for your feedback!

SectionΒ 2. ChapterΒ 4
some-alt