Basically, it comes in use for private and unique keys. No one can able to set the specific map if he/she doesn't share the instance as the property of the symbol. You can take the below code as a reference:
var map = {};
var symbol1 = Symbol("prop");
var symbol2 = Symbol("prop"); // same name, different instance – so it's a different symbol!
map[symbol1] = 1;
map[symbol2] = 2; // doesn't override the previous symbol's value
console.log(map[symbol1] + map[symbol2]); // logs 3
I hope this will help.
Want to know more about Java? Prefer this tutorial on Learn Java.
Want to become a Java Expert? Join Java Training now!!