ES6 Symbols

1 · Alan Storm · July 14, 2020, 11:45 a.m.
Summary
One pattern that keeps coming up when I’m spelunking older NPM packages for Node.js is using Symbols to define properties on an object. A Symbol is a way to create an object that’s a unique identifier in a javascript program. There’s a global function named Symbol you can use to create you symbol objects const symbol1 = Symbol('foo') const symbol2 = Symbol('baz') const symbol3 = Symbol('bar') The syntax is a little weird — usually a title case identifier like Symbol would indicate a constructor-...