2 ## ECMAScript 6 Symbol polyfill
4 For more information about symbols see following links
5 - [Symbols in ECMAScript 6 by Axel Rauschmayer](http://www.2ality.com/2014/12/es6-symbols.html)
6 - [MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol)
7 - [Specification](http://people.mozilla.org/~jorendorff/es6-draft.html#sec-symbol-constructor)
11 Underneath it uses real string property names which can easily be retrieved, however accidental collision with other property names is unlikely.
15 It’s safest to use *es6-symbol* as a [ponyfill](http://kikobeats.com/polyfill-ponyfill-and-prollyfill/) – a polyfill which doesn’t touch global objects:
18 var Symbol = require('es6-symbol');
21 If you want to make sure your environment implements `Symbol` globally, do:
24 require('es6-symbol/implement');
27 If you strictly want to use polyfill even if native `Symbol` exists (hard to find a good reason for that), do:
30 var Symbol = require('es6-symbol/polyfill');
35 Best is to refer to [specification](http://people.mozilla.org/~jorendorff/es6-draft.html#sec-symbol-objects). Still if you want quick look, follow examples:
38 var Symbol = require('es6-symbol');
40 var symbol = Symbol('My custom symbol');
44 console.log(x[symbol]); 'foo'
48 if (possiblyIterable[Symbol.iterator]) {
49 iterator = possiblyIterable[Symbol.iterator]();
50 result = iterator.next();
52 console.log(result.value);
53 result = iterator.next();
63 $ npm install es6-symbol
67 To port it to Browser or any other (non CJS) environment, use your favorite CJS bundler. No favorite yet? Try: [Browserify](http://browserify.org/), [Webmake](https://github.com/medikoo/modules-webmake) or [Webpack](http://webpack.github.io/)
69 ## Tests [![Build Status](https://travis-ci.org/medikoo/es6-symbol.png)](https://travis-ci.org/medikoo/es6-symbol)