Course Banner

The Symbol Type

A JavaScript Symbol is a primitive datatype just like Number, String, or Boolean.

It represents a unique "hidden" identifier that no other code can accidentally access.

For instace, if different coders want to add a property to a person object belonging to a third-party code, they could mix each others values.

Using Symbol() to create a unique identifiers, solves this problem:

Using JavaScript Symbol()

<!DOCTYPE html>



<h2>Using JavaScript Symbol()</h2>

<p id="demo"></p>


const person = {

  firstName: "John",

  lastName: "Doe",

  age: 50,

  eyeColor: "blue"


let id = Symbol('id'); = 140353;

document.getElementById("demo").innerHTML =;