Standard built-ins

Symbol()

Try the free JavaScript compiler

Creates a fresh symbol. An optional description is converted to a string unless it is undefined; it does not determine identity. Symbol is callable but not constructible. Registered symbols are obtained through Symbol.for instead.

Formal Syntax & Structure

javascript syntaxjavascript
Symbol(description)

Parameters & Attributes

NameTypeDescription
descriptionanyOptional descriptive label; not a registry key.

Return Value

symbol

A fresh distinct symbol.

Working Example

Example Snippetjavascript
const token = Symbol("tag");console.log(typeof token);
JavaScript Reference