Lovely bit of work, this: @mathias wrote code to derive a regex for valid JavaScript identifiers, which I’d totally have used if the regex was smaller than 16KB. https://mathiasbynens.be/demo/javascript-identifier-regex …
So, I went with this awful cut down version: /^(?!(?:)$)(?:[\$A-Z_a-z])(?:[\$0-9A-Z_a-z])*$/
How about this? const regexIdentifierName = /^(?:[$_\p{ID_Start}])(?:[$_\u200C\u200D\p{ID_Continue}])*$/u;https://github.com/tc39/proposal-regexp-unicode-property-escapes#other-examples …
-
-
Could be fun. I’m not worried about false negatives, though: it’s the false positives I’m worried about. Could do with some experiments on which reserved words work as a properly name.
-
I wrote a blog post on that: https://mathiasbynens.be/notes/javascript-properties …
- 1 more reply
New conversation -
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.
JavaScript, HTML, CSS, HTTP, performance, security, Bash, Unicode, i18n, macOS.