|
|
|
|
|
by masklinn
1102 days ago
|
|
> So if we know Symbol.dispose in advance we can simplify the code? Symbol.dispose is Symbol.dispose. It's a singleton object and that's the sole reference to it. > Why did they make it so unwieldy especially since it is a new functionality not requiring backwards compatibility hacks? 1. Bare names in object keys are strings, so there needs to be an "escaping" syntax for non-string keys, that is what the brackets have done since 2015, in order to support the addition of... 2. Non-conflicting keys, which are what symbols are: symbols are guaranteed not to conflict with any string, and even to be unique unless they're created using `Symbol.for` (which accesses and stores into a global registry, this allows adding protocol methods to all objects without the risk of breaking existing any (by triggering new and unexpected behaviour). |
|