3 ms·
Symbol.match is not the match function, it is a Symbol which can be used as a property key on an object that is supposed to behave like a regular expression. T
by jchw 4y ago
Symbol.match is not the match function, it is a Symbol which can be used as a property key on an object that is supposed to behave like a regular expression.
The purpose of having Symbol values is to ensure the property keys are unique and can't collide with string keys that predate new standards.
- Waterluvian 4y agoOhhhh okay. So it’s just a flag describing expectations about an object. And as a Symbol it doesn’t interfere with any other part of the object such as properties or iteration.
- acdibble 4y agoAlso known as "well-known symbols". https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol#well-known_symbols https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe...