3 ms·
[Symbol.dispose] is a way of creating an entry whose key is the value of the expression Symbol.dispose in the same way obj[Symbol.dispose] is a way of accessing
by masklinn 1y ago
[Symbol.dispose] is a way of creating an entry whose key is the value of the expression Symbol.dispose in the same way obj[Symbol.dispose] is a way of accessing it.
The parens are just the method definition shorthand, so it’s a shorter way of writing
[Symbol.dispose]: function()
Bracketing was introduced because Javascript was originally defined to use bare keys so
foo: bar
Defines an entry with the key `”foo”`, rather than an entry whose key is the value for the variable `foo`. Thus to get the latter you use
[foo]: bar