JS: Symbol Object

By Xah Lee. Date: . Last updated: .

New in ES2015.

Symbol is the value of the property key "Symbol" of the global object. [JS: the Global Object]

console.log( window.Symbol === Symbol ); // true


Symbol is a function.

[see JS: Value Types]

// type of Symbol
console.log ( typeof Symbol === "function" ); // true


Parent of Symbol is Function.prototype. [see JS: Prototype and Inheritance]

console.log ( Reflect.getPrototypeOf ( Symbol ) === Function.prototype ); // true


Purpose of Symbol is:

  1. To create values of symbol type.
  2. Holds value properties and function properties that are useful for symbol values.
  3. Holds the property Symbol.prototype, which is the parent of all symbol objects.

[see JS: Symbol Tutorial]

[see JS: Value Types]

Symbol Constructor


  1. Symbol.prototype
  1. Symbol.for ( key )
  2. Symbol.hasInstance
  3. Symbol.isConcatSpreadable
  4. Symbol.iterator
  5. Symbol.keyFor ( sym )
  6. Symbol.match
  7. Symbol.replace
  8. Symbol.search
  9. Symbol.species
  10. Symbol.split
  11. Symbol.toPrimitive
  12. Symbol.toStringTag
  13. Symbol.unscopables

2017-02-10 following is work in progress.

Symbol.for ( key )

Symbol.for(string) → access shared symbols registry.

ECMAScript® 2016 Language Specification#sec-symbol.for


ECMAScript® 2016 Language Specification#sec-symbol.hasinstance


ECMAScript® 2016 Language Specification#sec-symbol.isconcatspreadable


ECMAScript® 2016 Language Specification#sec-symbol.iterator

Symbol.keyFor ( sym )

ECMAScript® 2016 Language Specification#sec-symbol.keyfor


ECMAScript® 2016 Language Specification#sec-symbol.match


ECMAScript® 2016 Language Specification#sec-symbol.replace


ECMAScript® 2016 Language Specification#sec-symbol.search


ECMAScript® 2016 Language Specification#sec-symbol.species


ECMAScript® 2016 Language Specification#sec-symbol.split


ECMAScript® 2016 Language Specification#sec-symbol.toprimitive


ECMAScript® 2016 Language Specification#sec-symbol.tostringtag


ECMAScript® 2016 Language Specification#sec-symbol.unscopables

Well-Known (Predefined) Symbols

Well-Known symbols are symbols predefined in JavaScript.

Well-known symbols are built-in Symbol values They are typically used as the keys of properties whose values serve as extension points. Unless otherwise specified, well-known symbols values are shared by all Code Realms.

Well-Known symbols are denoted with 2 at signs in front, like this: @@iterator


the operator instanceof is now a method of function, with property key [Symbol.hasInstance]. someting like o instanceof f same as f[Symbol.hasInstance](o). this makes it extensible. todo


Symbol.match method for customizing str.match(obj). todo

Well-known Symbols

JS Symbol

  1. Symbol Tutorial

Like it? Help me by telling your friends. Or, Put $5 at patreon.

Or, Buy JavaScript in Depth

If you have a question, put $5 at patreon and message me.

Web Dev Tutorials

  1. HTML
  2. Visual CSS
  3. JS in Depth
  4. JS Object Ref
  5. DOM Scripting
  6. SVG
  7. Blog