canonical
Version:
Canonical code style linter and formatter for JavaScript, SCSS, CSS and JSON.
20 lines (13 loc) • 519 B
Markdown
[](http://badge.fury.io/js/symbol)
[](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-symbol-objects), in your ES5.
If `Symbol` is already defined, it will be used. Otherwise, this implements as much of the `Symbol` spec as is possible with plain JavaScript.
```js
var Symbol = require('symbol');
var key = Symbol();
var obj = {};
obj[key] = 'foo';
console.log(obj[key]); // 'foo'
console.log(Object.keys(obj)); // []
```