O'Reilly logo

Get Programming with JavaScript Next: New features of ECMAScript 2015, 2016, and beyond by JD Isaacks

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

Lesson 13. Symbol—a new primitive

After reading lesson 13, you will

  • Know how to use symbols as constants
  • Know how to use symbols as object keys
  • Know how to create behavior hooks with global symbols
  • Know how to modify object behavior with well-known symbols

In JavaScript there are objects and there are primitives. The primitives of JavaScript are strings, numbers, Booleans (true or false), null, and undefined. Symbol is a new primitive added in ES2015 and is the first primitive added to JavaScript since its creation. A symbol is a unique value that’s used for hooking into the behavior of built-in JavaScript objects. Symbols can be broken into three categories:

  1. Unique symbols
  2. Global symbols
  3. Well-known symbols
Consider this

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