bhylu.com

Advertisements

JS Symbols

Symbols create unique values suitable for property keys. The description helps debugging but does not determine identity.

Where to run this

This example uses the JavaScript console playground. Select Run to execute it; the example does not run on this lesson page.

A practical example

JavaScript

const first = Symbol("id");
const second = Symbol("id");
console.log(first === second);

What happens

The symbols are different despite matching descriptions.