2 ## ECMAScript6 Symbol polyfill
6 - Underneath it uses real string property names which can easily be retrieved (however accidental collision with other property names is unlikely)
7 - As it needs custom `toString` behavior to work properly. Original `Symbol.prototype.toString` couldn't be implemented as specified, still it's accessible as `Symbol.prototoype.properToString`
11 If you want to make sure your environment implements `Symbol`, do:
14 require('es6-symbol/implement');
17 If you'd like to use native version when it exists and fallback to polyfill if it doesn't, but without implementing `Symbol` on global scope, do:
20 var Symbol = require('es6-symbol');
23 If you strictly want to use polyfill even if native `Symbol` exists (hard to find a good reason for that), do:
26 var Symbol = require('es6-symbol/polyfill');
31 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:
34 var Symbol = require('es6-symbol');
36 var symbol = Symbol('My custom symbol');
40 console.log(x[symbol]); 'foo'
44 if (possiblyIterable[Symbol.iterator]) {
45 iterator = possiblyIterable[Symbol.iterator]();
46 result = iterator.next();
48 console.log(result.value);
49 result = iterator.next();
59 $ npm install es6-symbol
63 You can easily bundle _es6-symbol_ for browser with [modules-webmake](https://github.com/medikoo/modules-webmake)
65 ## Tests [](https://travis-ci.org/medikoo/es6-symbol)