Symbols in JavaScript play very important role. This is the last tutorial of our free JavaScript ES6+ free crash course 2025 and in this post we have explained code examples of Symbol with its brief definition. Not just symbols if you want to go through other tutorials you can read Arrow Functions, Destructuring, Rest Operators, Template Literal Classes & Inheritance, Modules promises, Aync/Await , Const, Let & Block Scoping, Enhanced Object Literals, default parameters and Map & Set. So baically the Symbol is a new primitive type introduced in ES6 for creating unique identifiers.
const sym1 = Symbol();
const sym2 = Symbol('description'); const sym3 = Symbol('description');
console.log(sym2 === sym3); // false
// Symbols as property keys const obj = {
[sym1]: 'Value for sym1'
};
console.log(obj[sym1]); // 'Value for sym1'
// Well-known symbols const iterable = {
[Symbol.iterator]: function* () { yield 1;
yield 2;
yield 3;
}
};
for (let value of iterable) {
console.log(value); // 1, 2, 3
}
Big Takeaways
- Use Symbols for creating non-string property keys
- Leverage well-known Symbols to customize object behavior
Common Issues
- Symbols are not automatically converted to strings
- Symbols are not enumerable in for…in loops or Object.keys()
This is the last tutorial of free JavaScript crash course of 2025. Please let us know in the comments if you faced any difficulty through out this course.












