Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Symbols 1/3 | 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

Symbols 1/3

The symbol is a primitive data type that is used to create a unique identifier. Symbols are unchallengeable and unique.

Creation of symbols

We use the global Symbol() function to create a new symbol. We will work briefly with the functions in the later section but you have to learn that to create a primitive symbol we will use Symbol().

12
let s = Symbol('foo'); console.log(s.toString());
copy

Note: Symbol variable should be converted to string if you want to use it as a string value. That can be done by using .toString() method.

A unique value is created every time the Symbol() function is called or used and these values are not equal to each other (they are unique).

1
console.log(Symbol() === Symbol());
copy

Even when we pass equal arguments, the result is still different, for example:

1
console.log(Symbol('Berlin') == Symbol('Berlin'));
copy

Завдання

You have to check that Symbol('Monaco') and Symbol('Istanbul') are equal or not and display the result on the console.

Завдання

You have to check that Symbol('Monaco') and Symbol('Istanbul') are equal or not and display the result on the console.

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

Все було зрозуміло?

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

Symbols 1/3

The symbol is a primitive data type that is used to create a unique identifier. Symbols are unchallengeable and unique.

Creation of symbols

We use the global Symbol() function to create a new symbol. We will work briefly with the functions in the later section but you have to learn that to create a primitive symbol we will use Symbol().

12
let s = Symbol('foo'); console.log(s.toString());
copy

Note: Symbol variable should be converted to string if you want to use it as a string value. That can be done by using .toString() method.

A unique value is created every time the Symbol() function is called or used and these values are not equal to each other (they are unique).

1
console.log(Symbol() === Symbol());
copy

Even when we pass equal arguments, the result is still different, for example:

1
console.log(Symbol('Berlin') == Symbol('Berlin'));
copy

Завдання

You have to check that Symbol('Monaco') and Symbol('Istanbul') are equal or not and display the result on the console.

Завдання

You have to check that Symbol('Monaco') and Symbol('Istanbul') are equal or not and display the result on the console.

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

Все було зрозуміло?

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

Symbols 1/3

The symbol is a primitive data type that is used to create a unique identifier. Symbols are unchallengeable and unique.

Creation of symbols

We use the global Symbol() function to create a new symbol. We will work briefly with the functions in the later section but you have to learn that to create a primitive symbol we will use Symbol().

12
let s = Symbol('foo'); console.log(s.toString());
copy

Note: Symbol variable should be converted to string if you want to use it as a string value. That can be done by using .toString() method.

A unique value is created every time the Symbol() function is called or used and these values are not equal to each other (they are unique).

1
console.log(Symbol() === Symbol());
copy

Even when we pass equal arguments, the result is still different, for example:

1
console.log(Symbol('Berlin') == Symbol('Berlin'));
copy

Завдання

You have to check that Symbol('Monaco') and Symbol('Istanbul') are equal or not and display the result on the console.

Завдання

You have to check that Symbol('Monaco') and Symbol('Istanbul') are equal or not and display the result on the console.

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

Все було зрозуміло?

The symbol is a primitive data type that is used to create a unique identifier. Symbols are unchallengeable and unique.

Creation of symbols

We use the global Symbol() function to create a new symbol. We will work briefly with the functions in the later section but you have to learn that to create a primitive symbol we will use Symbol().

12
let s = Symbol('foo'); console.log(s.toString());
copy

Note: Symbol variable should be converted to string if you want to use it as a string value. That can be done by using .toString() method.

A unique value is created every time the Symbol() function is called or used and these values are not equal to each other (they are unique).

1
console.log(Symbol() === Symbol());
copy

Even when we pass equal arguments, the result is still different, for example:

1
console.log(Symbol('Berlin') == Symbol('Berlin'));
copy

Завдання

You have to check that Symbol('Monaco') and Symbol('Istanbul') are equal or not and display the result on the console.

Перейдіть на комп'ютер для реальної практикиПродовжуйте з того місця, де ви зупинились, використовуючи один з наведених нижче варіантів
Секція 3. Розділ 27
Перейдіть на комп'ютер для реальної практикиПродовжуйте з того місця, де ви зупинились, використовуючи один з наведених нижче варіантів
We're sorry to hear that something went wrong. What happened?
some-alt