Symbol and Unique Symbol
In this lesson, we see how TypeScript strongly types the primitive type, symbol, and its subtype, unique symbol.
We'll cover the following
Symbol
Symbol
is a primitive type in ECMAScript 2015 and beyond. TypeScript supports the standard. The equal sign assigns a value to a symbol without the keyword new
but must have parentheses, like an object. A symbol’s goal is to provide a unique and immutable variable.
A symbol can take a parameter with a string value. Defining two symbols with the same parameter will produce a different symbol. In fact, the parameter is just there to help developers when printing the symbol to the console. It’s a way to differentiate them visually.
Get hands-on with 1400+ tech skills courses.