We've seen how to create unique symbols to use as keys in a local context. However, sometimes, we want to be able to interact with a data structure. Symbols can be made to work in this case as well.
Using Symbol.for to create a global instance
Getting ready
This recipe assumes that you already have a workspace that allows you to create and run ES modules in your browser. If you don't, refer to the first two chapters.
How to do it...
- Open your command-line application and navigate to your workspace.
- Create a new folder named 11-02-symbol-for-global.
- Copy or create...