Search⌘ K
AI Features

Symbols

Explore how Symbols create unique and private object properties in JavaScript. Understand their use for private keys and customizing iteration with well-known symbols in arrays and HTML collections.

We'll cover the following...

Symbols are a new primitive data type in JavaScript, they can to create anonymous keys for object properties, among other things. One key feature of these properties is that they do not show up in a for..in loop. Symbols are created using the Symbol function and passed a description.

Javascript (babel-node)
const mySym = Symbol('name');

No two symbols are the same, if we created another Symbol('name') it would be completely different.

Symbols for private keys

Because of a ...