4 ms·
JavaScript doesn't guarantee the order of keys. [edit] Also, the API makes less sense because JavaScript isn't statically typed so you can make up the result o
by ajanuary 11y ago
JavaScript doesn't guarantee the order of keys.
[edit]
Also, the API makes less sense because JavaScript isn't statically typed so you can make up the result object on the fly.
match('^(?<user>\w+)@(?<host>[^@]+)$', 'joe@example.com') => {'user': 'joe', 'host': 'example.com'}
- inglor 11y agoYes it does - it does for getOwnPropertyNames but not for Object.keys.
- ajanuary 11y agoSeems I might be outdated, and ES6 does define an order.
- masklinn 11y ago> [edit] Also, the API makes less sense because JavaScript isn't statically typed so you can make up the result object on the fly. But now you need to parse the string and correctly extract named groups before flogging that to the regex engine, whereas the other way around you do some string concatenation then match back on the groups by index.
- inglor 11y agoJavaScript has no named capturing groups.