O'Reilly logo

Rediscovering JavaScript by Venkat Subramaniam

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Symbol—A New Primitive Type

JavaScript previously had five primitive types: number, string, boolean, null, and, undefined; now it has one more. Symbol is a new primitive type in JavaScript intended for limited specialized use. Symbols can be used for three distinct purposes:

  • To define properties for objects in such a way they don’t appear during normal iteration—these properties are not private; they’re just not easily discovered like other properties.

  • To easily define a global registry or dictionary of objects.

  • To define some special well-known methods in objects; this feature, which fills the void of interfaces, is arguably one of the most important purposes of Symbol.

Interfaces in languages like Java and C# are useful for design by contract ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required