Symbol is a primitive data type, introduced in ES6 version, which creates an immutable and unique symbol. It is used to create unique object keys and identifiers.

Syntax

const mySymbol = Symbol();
const mySymbol = Symbol(description); 

description is optional and it is a string.

Create a Symbol

Symbol can be created using Symbol constructor or passing a string as argument in Symbol constructor.

<script>
const mySymbol1 = Symbol();
const mySymbol2 = Symbol("yourshala");
const mySymbol3 = Symbol("HelloWorld");
</script>

Above example will create three different unique symbols.