Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
What are Data-types? | Data Types and Variables
Introduction to JavaScript (staging)
course content

Зміст курсу

Introduction to JavaScript (staging)

Introduction to JavaScript (staging)

1. Introduction
2. JavaScript syntax
3. Data Types and Variables

bookWhat are Data-types?

What are Data-types?

The values which we assign to the variables are of a specific type which is called the data type of that specific variable. We can assign numbers, string, boolean, null, undefined, array, object, functions, and symbols to variables.

Introduction to different Data-types

Following is a brief introduction to the commonly used data types in JavaScript. We will go through these in detail in the upcoming chapters, but for now, let’s just get a basic understanding of all these.

  • Number

Numbers are always floating-point numbers so both the integers as well as floating-point numbers are simply numbers in JavaScript.

12
let totalCoins=100; console.log(totalCoins)
copy
  • BigInt: BigInt is used to represent numbers of arbitrary lengths. A BigInt number can be generated by appending n at the end of a number.
123
// the "n" at the end means it's a BigInt const bigInt = 12345678901234567890123n; console.log(bigInt);
copy

Strings:
We use quotes to represent the strings. They are commonly used to deal with text.

12
let comment="good"; console.log(comment);
copy
  • Boolean (logical type): In this type, we have only two values: true and false. We use true for “Yes”, and false is used for “No”. For instance, if we want to store the value of "It's raining" we will set the value to true and if it is not raining then we will set the value false.
12
let isRaining = true; console.log(isRaining);
copy
  • null: The null is a special value that represents “nothing”, “empty”, or “value unknown”.
12
let selectedColor = null; console.log(selectedColor)
copy
  • Undefined: In JavaScript, a default value of undefined is assigned to the variable if we do not assign a value to it.
12
let age; console.log(age);
copy

The typeof Operator:

The typeof operator is used to get the type of the value or variable. It’s useful to quickly check the types of values that are assigned to the variable. To check the type we use the typeof keyword and pass the variable inside parentheses.

12
let drink="soda"; console.log('typeof("drink"):', typeof(drink));
copy

Завдання

Check the type of the following variable and display it on the console.

Switch to desktopПерейдіть на комп'ютер для реальної практикиПродовжуйте з того місця, де ви зупинились, використовуючи один з наведених нижче варіантів
Все було зрозуміло?

Як ми можемо покращити це?

Дякуємо за ваш відгук!

Секція 3. Розділ 2
toggle bottom row

bookWhat are Data-types?

What are Data-types?

The values which we assign to the variables are of a specific type which is called the data type of that specific variable. We can assign numbers, string, boolean, null, undefined, array, object, functions, and symbols to variables.

Introduction to different Data-types

Following is a brief introduction to the commonly used data types in JavaScript. We will go through these in detail in the upcoming chapters, but for now, let’s just get a basic understanding of all these.

  • Number

Numbers are always floating-point numbers so both the integers as well as floating-point numbers are simply numbers in JavaScript.

12
let totalCoins=100; console.log(totalCoins)
copy
  • BigInt: BigInt is used to represent numbers of arbitrary lengths. A BigInt number can be generated by appending n at the end of a number.
123
// the "n" at the end means it's a BigInt const bigInt = 12345678901234567890123n; console.log(bigInt);
copy

Strings:
We use quotes to represent the strings. They are commonly used to deal with text.

12
let comment="good"; console.log(comment);
copy
  • Boolean (logical type): In this type, we have only two values: true and false. We use true for “Yes”, and false is used for “No”. For instance, if we want to store the value of "It's raining" we will set the value to true and if it is not raining then we will set the value false.
12
let isRaining = true; console.log(isRaining);
copy
  • null: The null is a special value that represents “nothing”, “empty”, or “value unknown”.
12
let selectedColor = null; console.log(selectedColor)
copy
  • Undefined: In JavaScript, a default value of undefined is assigned to the variable if we do not assign a value to it.
12
let age; console.log(age);
copy

The typeof Operator:

The typeof operator is used to get the type of the value or variable. It’s useful to quickly check the types of values that are assigned to the variable. To check the type we use the typeof keyword and pass the variable inside parentheses.

12
let drink="soda"; console.log('typeof("drink"):', typeof(drink));
copy

Завдання

Check the type of the following variable and display it on the console.

Switch to desktopПерейдіть на комп'ютер для реальної практикиПродовжуйте з того місця, де ви зупинились, використовуючи один з наведених нижче варіантів
Все було зрозуміло?

Як ми можемо покращити це?

Дякуємо за ваш відгук!

Секція 3. Розділ 2
toggle bottom row

bookWhat are Data-types?

What are Data-types?

The values which we assign to the variables are of a specific type which is called the data type of that specific variable. We can assign numbers, string, boolean, null, undefined, array, object, functions, and symbols to variables.

Introduction to different Data-types

Following is a brief introduction to the commonly used data types in JavaScript. We will go through these in detail in the upcoming chapters, but for now, let’s just get a basic understanding of all these.

  • Number

Numbers are always floating-point numbers so both the integers as well as floating-point numbers are simply numbers in JavaScript.

12
let totalCoins=100; console.log(totalCoins)
copy
  • BigInt: BigInt is used to represent numbers of arbitrary lengths. A BigInt number can be generated by appending n at the end of a number.
123
// the "n" at the end means it's a BigInt const bigInt = 12345678901234567890123n; console.log(bigInt);
copy

Strings:
We use quotes to represent the strings. They are commonly used to deal with text.

12
let comment="good"; console.log(comment);
copy
  • Boolean (logical type): In this type, we have only two values: true and false. We use true for “Yes”, and false is used for “No”. For instance, if we want to store the value of "It's raining" we will set the value to true and if it is not raining then we will set the value false.
12
let isRaining = true; console.log(isRaining);
copy
  • null: The null is a special value that represents “nothing”, “empty”, or “value unknown”.
12
let selectedColor = null; console.log(selectedColor)
copy
  • Undefined: In JavaScript, a default value of undefined is assigned to the variable if we do not assign a value to it.
12
let age; console.log(age);
copy

The typeof Operator:

The typeof operator is used to get the type of the value or variable. It’s useful to quickly check the types of values that are assigned to the variable. To check the type we use the typeof keyword and pass the variable inside parentheses.

12
let drink="soda"; console.log('typeof("drink"):', typeof(drink));
copy

Завдання

Check the type of the following variable and display it on the console.

Switch to desktopПерейдіть на комп'ютер для реальної практикиПродовжуйте з того місця, де ви зупинились, використовуючи один з наведених нижче варіантів
Все було зрозуміло?

Як ми можемо покращити це?

Дякуємо за ваш відгук!

What are Data-types?

The values which we assign to the variables are of a specific type which is called the data type of that specific variable. We can assign numbers, string, boolean, null, undefined, array, object, functions, and symbols to variables.

Introduction to different Data-types

Following is a brief introduction to the commonly used data types in JavaScript. We will go through these in detail in the upcoming chapters, but for now, let’s just get a basic understanding of all these.

  • Number

Numbers are always floating-point numbers so both the integers as well as floating-point numbers are simply numbers in JavaScript.

12
let totalCoins=100; console.log(totalCoins)
copy
  • BigInt: BigInt is used to represent numbers of arbitrary lengths. A BigInt number can be generated by appending n at the end of a number.
123
// the "n" at the end means it's a BigInt const bigInt = 12345678901234567890123n; console.log(bigInt);
copy

Strings:
We use quotes to represent the strings. They are commonly used to deal with text.

12
let comment="good"; console.log(comment);
copy
  • Boolean (logical type): In this type, we have only two values: true and false. We use true for “Yes”, and false is used for “No”. For instance, if we want to store the value of "It's raining" we will set the value to true and if it is not raining then we will set the value false.
12
let isRaining = true; console.log(isRaining);
copy
  • null: The null is a special value that represents “nothing”, “empty”, or “value unknown”.
12
let selectedColor = null; console.log(selectedColor)
copy
  • Undefined: In JavaScript, a default value of undefined is assigned to the variable if we do not assign a value to it.
12
let age; console.log(age);
copy

The typeof Operator:

The typeof operator is used to get the type of the value or variable. It’s useful to quickly check the types of values that are assigned to the variable. To check the type we use the typeof keyword and pass the variable inside parentheses.

12
let drink="soda"; console.log('typeof("drink"):', typeof(drink));
copy

Завдання

Check the type of the following variable and display it on the console.

Switch to desktopПерейдіть на комп'ютер для реальної практикиПродовжуйте з того місця, де ви зупинились, використовуючи один з наведених нижче варіантів
Секція 3. Розділ 2
Switch to desktopПерейдіть на комп'ютер для реальної практикиПродовжуйте з того місця, де ви зупинились, використовуючи один з наведених нижче варіантів
some-alt