JavaScript

JavaScript

Made by DeepSource

Require symbol description JS-0250

Performance
Minor

The Symbol function may have an optional description:

var foo = Symbol("some description");

var someString = "some description";
var bar = Symbol(someString);

Using description promotes easier debugging: when a symbol is logged the description is used:

var foo = Symbol("some description");

> console.log(foo);
// Symbol(some description)

It may facilitate identifying symbols when one is observed during debugging.

Bad Practice

var foo = Symbol();

Recommended

var foo = Symbol("some description");

var someString = "some description";
var bar = Symbol(someString);