From the course: Learning ECMAScript 6+ (ES6+)
Unlock the full course today
Join today to access over 22,700 courses taught by industry experts or purchase this course individually.
Using symbols - JavaScript Tutorial
From the course: Learning ECMAScript 6+ (ES6+)
Using symbols
- [Instructor] At the core of all of our JavaScript applications are primitives. Primitives in JavaScript are types like numbers, strings, arrays, objects, and more. Symbols are a new primitive type in JavaScript that were given to us with ES6. Symbols are primarily used as unique IDs. What's nice about them is that they're not going to conflict with object string keys. So we create a symbol by using a factory function. In other words, we're going to call a function to create this symbol. So we're going to create an ID equal to symbol. Then I'm going to create an object with a couple different keys. So we'll have one for title and then inside of the topics array, we'll just have some topics related to JavaScript. Strings, arrays, objects. The next thing I want to do is let's just console log our course info. We'll take a look at that in our console and we should see the title and the topics are there. Now right…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.