From the course: Learn JavaScript: Write Modern Code with JavaScript ESNext
Unlock this course with a free trial
Join today to access over 25,500 courses taught by industry experts.
Learn about JavaScript’s Symbol type - JavaScript Tutorial
From the course: Learn JavaScript: Write Modern Code with JavaScript ESNext
Learn about JavaScript’s Symbol type
- The very last data type that we're going to look at in this course is something called symbols. Symbols are probably one of the least self-explanatory data types, but they're still extremely useful in many cases. Before we go into some of the use cases of symbols, let's discuss how to create them and some of their basic properties. The main way to define a symbol is like this, using the symbol constructor. The string that we pass to the constructor is called the description of the symbol, and we can always just leave that argument out entirely if we want to. Now, the whole idea of symbols is that no two distinct symbols will ever be equal to each other. So even if we create two symbols with the exact same description when we test if they're equal, and equality testing, by the way, is something we'll talk about shortly. JavaScript will tell us that they're not equal. In fact, the only way that two symbols will ever be equal is if we either compare the same symbol to itself or if we…
Contents
-
-
-
-
(Locked)
Learning objectives1m 14s
-
(Locked)
Learn the types3m 20s
-
(Locked)
Learn about JavaScript’s Number type5m 14s
-
(Locked)
Learn about JavaScript’s String type5m 14s
-
(Locked)
Learn about JavaScript’s Boolean type2m 4s
-
Learn about JavaScript’s Object type6m 9s
-
(Locked)
Learn about arrays in JavaScript3m 7s
-
(Locked)
Learn about JavaScript’s function type2m 20s
-
(Locked)
Learn about JavaScript’s undefined type2m 27s
-
(Locked)
Learn about JavaScript’s BigInt type2m 47s
-
(Locked)
Learn about JavaScript’s Symbol type3m 17s
-
(Locked)
-
-
-
-
-
-
-
-
-
-