The typeof operator

The typeof operator is used to determine the type of value a particular variable/constant is held for Symbol, typeof outputs symbol. Here is an example to demonstrate the same:

const s = Symbol();console.log(typeof s); //Outputs "symbol"

Using the typeof operator is the only way to identify whether a variable holds a symbol.

Get Learn ECMAScript - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.