Preview:
// Create a symbol
const uniqueSymbol = Symbol('unique');

// Using a symbol as a key for an object
const obj = {
  [uniqueSymbol]: 'This is a unique value'
};

console.log(obj[uniqueSymbol]);  // Output: This is a unique value

// Symbols are guaranteed to be unique
const anotherSymbol = Symbol('unique');
console.log(uniqueSymbol === anotherSymbol);  // Output: false
downloadDownload PNG downloadDownload JPEG downloadDownload SVG

Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!

Click to optimize width for Twitter